systemd-journald 无法在 CentOS 7 上启动

systemd-journald 无法在 CentOS 7 上启动

从一周前开始,journald 就无法启动了。启动时,它会启动并记录启动消息和一些其他服务启动日志,然后在启动时突然关闭Switch Root

Mar 18 05:22:56 playground1.local systemd-journal[96]: Runtime journal is using 8.0M (max allowed 391.1M, trying to leave 586.7M free of 3.8G available → current limit 391.1M).
Mar 18 05:22:56 playground1.local systemd-journal[96]: Runtime journal is using 8.0M (max allowed 391.1M, trying to leave 586.7M free of 3.8G available → current limit 391.1M).
Mar 18 05:22:56 playground1.local kernel: Initializing cgroup subsys cpuset
Mar 18 05:22:56 playground1.local kernel: Initializing cgroup subsys cpu
Mar 18 05:22:56 playground1.local kernel: Initializing cgroup subsys cpuacct
Mar 18 05:22:56 playground1.local kernel: Linux version 3.10.0-327.10.1.el7.x86_64 ([email protected]) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Tue Feb 16 17:03:50 UTC 2016
Mar 18 05:22:56 playground1.local kernel: Command line: BOOT_IMAGE=/vmlinuz-3.10.0-327.10.1.el7.x86_64 root=/dev/mapper/centos-root ro rd.lvm.lv=centos/root rd.lvm.lv=centos/swap crashkernel=auto rhgb quiet LANG=en_US.UTF-8 console=ttyS0 systemd.debug

...

Mar 18 05:22:57 playground1.local systemd[1]: Reached target Switch Root.
Mar 18 05:22:57 playground1.local systemd[1]: Starting Switch Root.
Mar 18 05:22:57 playground1.local systemd[1]: Starting Switch Root...
Mar 18 05:22:57 playground1.local systemd[1]: Switching root.
Mar 18 05:22:57 playground1.local systemd-journal[96]: Journal stopped

如果我尝试手动启动它,它会很快失败:

[root@playground1 ~]# systemctl start systemd-journald.service
Job for systemd-journald.service failed because the control process exited with error code. See "systemctl status systemd-journald.service" and "journalctl -xe" for details.
[root@playground1 ~]# systemctl status systemd-journald.service
● systemd-journald.service - Journal Service
  Loaded: loaded (/usr/lib/systemd/system/systemd-journald.service; static; vendor preset: disabled)
  Active: failed (Result: start-limit) since Fri 2016-03-18 16:38:21 EDT; 21s ago
    Docs: man:systemd-journald.service(8)
          man:journald.conf(5)
  Process: 3404 ExecStart=/usr/lib/systemd/systemd-journald (code=exited, status=1/FAILURE)
Main PID: 3404 (code=exited, status=1/FAILURE)
  Status: "Shutting down..."
[root@playground1 ~]#

journalctl -xe打印启动日志,当手动启动服务时,它实际上不会向日志中写入任何内容。如果我删除日志文件,它就不会被创建。

手动运行是/usr/lib/systemd/systemd-journald一种工作方式,这意味着该过程已启动,并journalctl包含 journald 启动日志,但之后实际上没有记录任何其他内容。

systemd-journald.socket似乎也无法加载,这可能是失败的原因,但我在日志中没有看到有关它的任何内容:

[root@playground1 systemd]# systemctl status systemd-journald.socket
● systemd-journald.socket - Journal Socket
  Loaded: loaded (/usr/lib/systemd/system/systemd-journald.socket; static; vendor preset: disabled)
  Active: failed (Result: service-failed-permanent) since Fri 2016-03-18 16:46:24 EDT; 4min 8s ago
    Docs: man:systemd-journald.service(8)
          man:journald.conf(5)
  Listen: /run/systemd/journal/stdout (Stream)
          /run/systemd/journal/socket (Datagram)
          /dev/log (Datagram)

我认为这与 SELinux 无关,因为唯一被拒绝的是读取machine-id,这不应该成为大问题。但是,我在审计日志中注意到一个奇怪的事情,即该服务似乎启动了两次?

type=AVC msg=audit(1458334641.993:330): avc:  denied  { read } for  pid=3689 comm="systemd-journal" name="machine-id" dev="dm-0" ino=67109045 scontext=system_u:system_r:syslogd_t:s0 tcontext=system_u:object_r:unlabeled_t:s0 tclass=file
type=SYSCALL msg=audit(1458334641.993:330): arch=c000003e syscall=2 success=no exit=-13 a0=7fbc38ebf08f a1=80100 a2=7ffeb87c80bf a3=3 items=0 ppid=1 pid=3689 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="systemd-journal" exe="/usr/lib/systemd/systemd-journald" subj=system_u:system_r:syslogd_t:s0 key=(null)
type=SERVICE_START msg=audit(1458334642.002:331): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=systemd-journald comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'
type=SERVICE_START msg=audit(1458334642.002:332): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=systemd-journald comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_STOP msg=audit(1458334642.002:333): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=systemd-journald comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'

查看两条SERVICE_START消息,一条带有res=failed,另一条带有res=success

Google 告诉我,其他人都没有遇到这个问题。有什么想法吗?

答案1

AVC 表明正在读取的文件没有 SELinux 标签。

如果在创建文件时禁用了 SELinux,或者在不支持 SELinux 的文件系统(例如 vfat)上创建文件,则可能会发生这种情况。

如果有人禁用并重新启用了 SELinux,那么您应该能够通过重新标记文件系统来修复该问题(以及可能许多其他问题)。您可以在线执行此操作:

restorecon -r /

如果文件所在的文件系统不支持 SELinux,那么您需要将其替换为支持 SELinux 的文件系统,然后重新标记。

相关内容