了解更多银河麒麟操作系统全新产品,请点击访问
麒麟软件产品专区:https://product.kylinos.cn
开发者专区:https://developer.kylinos.cn
文档中心:https://documentkylinos.cn
服务器环境以及配置
【机型】
整机类型/架构: | HygonGenuine x86 |
【内核版本】
4.19.90-17.ky10.x86_64
【OS镜像版本】
银河麒麟高级服务器操作系统 Kylin-Server-10-SP1-x86-Release-Build04-20200711.iso
【nkvers 命令输出】
############## Kylin Linux Version #################
Release:
Kylin Linux Advanced Server release V10 (Tercel)
Kernel:
4.19.90-17.ky10.x86_64
Build:
Kylin Linux Advanced Server
release V10 (SP1) /(Tercel)-x86_64-Build04/20200711
#################################################
现象描述
systemd做init的容器中journal服务修改日志存储位置无效
现象分析
执行如下命令启动容器:
docker run -it --privileged cr.kylinos.cn/tmp/kylin-server-v10-sp1-amd64:Build20-20210518 /sbin/init
在终端上输出如下内容:
————————————————
[FAILED] Failed to start Flush Journal to Persistent Storage.
See 'systemctl status systemd-journal-flush.service' for details.
Starting Create Volatile Files and Directories...
[ OK ] Started Create Volatile Files and Directories.
Starting Security Auditing Service...
Starting Rebuild Journal Catalog...
Starting Network Time Synchronization...
[FAILED] Failed to start Rebuild Journal Catalog.
See 'systemctl status systemd-journal-catalog-update.service' for details.
Starting Update is Completed...
[ OK ] Started Update is Completed.
————————————————
进入容器后分别执行命令查看细节
执行systemctl status systemd-journal-flush.service得到输出
————————————————
[root@12b4d8a0538a /]# systemctl status systemd-journal-flush.service
● systemd-journal-flush.service - Flush Journal to Persistent Storage
Loaded: loaded (/usr/lib/systemd/system/systemd-journal-flush.service; static; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2024-05-08 14:04:19 CST; 33min ago
Docs: man:systemd-journald.service(8)
man:journald.conf(5)
Process: 36 ExecStart=/usr/bin/journalctl --flush (code=exited, status=127)
Main PID: 36 (code=exited, status=127)
May 08 14:04:19 12b4d8a0538a systemd[1]: Starting Flush Journal to Persistent Storage...
May 08 14:04:19 12b4d8a0538a systemd[1]: systemd-journal-flush.service: Main process exited, code=exited, status=127/n/a
May 08 14:04:19 12b4d8a0538a journalctl[36]: /usr/bin/journalctl: error while loading shared libraries: libqrencode.so.4: cannot open shared object file: No such file or directory
May 08 14:04:19 12b4d8a0538a systemd[1]: systemd-journal-flush.service: Failed with result 'exit-code'.
May 08 14:04:19 12b4d8a0538a systemd[1]: Failed to start Flush Journal to Persistent Storage.
————————————————
执行systemctl status systemd-journal-catalog-update.service得到输出
————————————————
[root@12b4d8a0538a /]# systemctl status systemd-journal-catalog-update.service
● systemd-journal-catalog-update.service - Rebuild Journal Catalog
Loaded: loaded (/usr/lib/systemd/system/systemd-journal-catalog-update.service; static; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2024-05-08 14:04:20 CST; 34min ago
Docs: man:systemd-journald.service(8)
man:journald.conf(5)
Process: 39 ExecStart=/usr/bin/journalctl --update-catalog (code=exited, status=127)
Main PID: 39 (code=exited, status=127)
May 08 14:04:19 12b4d8a0538a systemd[1]: Starting Rebuild Journal Catalog...
May 08 14:04:20 12b4d8a0538a journalctl[39]: /usr/bin/journalctl: error while loading shared libraries: libqrencode.so.4: cannot open shared object file: No such file or directory
May 08 14:04:20 12b4d8a0538a systemd[1]: systemd-journal-catalog-update.service: Main process exited, code=exited, status=127/n/a
May 08 14:04:20 12b4d8a0538a systemd[1]: systemd-journal-catalog-update.service: Failed with result 'exit-code'.
May 08 14:04:20 12b4d8a0538a systemd[1]: Failed to start Rebuild Journal Catalog.
————————————————
发现均缺少libqrencode.so.4文件,经查看,该文件属于qrencode包
将该包安装后,再使用/sbin/init启动容器,并执行journal服务修改日志存储位置操作可以生效。
分析结果
镜像中缺少qrencode包,该包是journal日志服务所需要的。
解决方案
方案一
可以在原镜像基础上制作新镜像,并安装qrencode包。之后使用新镜像修改journal日志存储位置即可。经研发自测有效,修改后效果如下图:
制作新镜像的dockerfile示例
其中,COPY行目的是为了替换可用的rpm下载源
方案二
或建议使用银河麒麟的init镜像。