Monday, March 5, 2012

Correcting broken startup of rsyslogd in a systemd unit file

My Fedora 17 Beefy Miracle alpha1 ARM system does not any contents in /var/log/messages. This is very impractical for troubleshooting. The command systemd-journalctl --no-tail shows that rsyslog.service fails to start correctly. Bummer!

Starting the daemon by hand, does not give any issues, so at least rsyslogd does not have an issue itself.

Checking the configuration, there are two unit files that may be used to start rsyslogd:
  1. /etc/systemd/system/syslog.service
  2. /etc/systemd/system/multi-user.target.wants/rsyslog.service
Both of these are symlinks to the unit file (/usr/lib/systemd/system/rsyslog.service) that comes with the rsyslogd package:
[Unit]
Description=System Logging Service

[Service]
EnvironmentFile=-/etc/sysconfig/rsyslog
ExecStartPre=/bin/systemctl stop systemd-kmsg-syslogd.service
ExecStart=/sbin/rsyslogd -n $SYSLOGD_OPTIONS
Sockets=syslog.socket
StandardOutput=null

[Install]
WantedBy=multi-user.target
All looks pretty neat, there is no very obvious issue here. However, on checking what this systemd-kmsg-syslogd.service is and does, I seem to be unable to find the unit file that defines this service. Just guessing, but if the ExecStartPre fails, it may not even try to start the rsyslog-daemon. Just commenting out the ExecStartPre is Not Done with the systemd configuration files. The advised way to change unit files which live under /usr/lib/systemd should be copied to the /etc/systemd/* directories instead:
# cd /etc/systemd/system
# rm syslog.service
# ln -s /usr/lib/systemd/system/rsyslog.service syslog.service
# cd multi-user.target.wants
# rm rsyslog.service
# ln -s ../syslog.service rsyslog.service
Now is is possible to change the unit file, without changing a file that may be replaced by a update of the rsyslog package. Commenting out the ExecStartPre in the new copy of syslog.service and rebooting, makes syslog work for me and /var/log/messages contains all the logs as expected.

More brokenness in my systemd configuration

One more annoying thing is that systemctl is not very usable:
# systemctl status rsyslog.service
Failed to get D-Bus connection: No connection to service manager.
Although D-Bus is running:
# ps v -C dbus-daemon
  PID TTY      STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
 1474 ?        Ss     0:00      6   265  2770  1436  0.3 /bin/dbus-daemon --system --address=systemd: --nofork --systemd-activation

I'm not sure what causes that (SElinux is disabled), but it is currently no big issue for me.
Post a Comment