systemctl 无法禁用服务,显示 upstart 错误

systemctl 无法禁用服务,显示 upstart 错误

在我的 Ubuntu 16.04 (Xenial) 服务器上,我无法禁用启动时自动启动的服务。我收到以下错误消息:

$ sudo systemctl disable puppet.service
...
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.

下次启动服务器时,“puppet agent”就会自动运行。

我猜测(根据错误消息)我的服务器处于 systemd(正在运行)和 Upstart 之间的某种奇怪的中间状态。仅供参考,此服务器曾经运行 Ubuntu 14(systemd 之前的版本),现已升级到 15.04、15.10 和 16.04。

看起来 systemd 正在运行,但 upstart 没有运行:

$ ps uax|grep init | grep -v grep
root         1  0.0  0.0 119780  6000 ?        Ss   May20   0:04 /sbin/init
$ ps uax|grep upstart|grep -v grep
$ ps uax|grep systemd|grep -v grep
root       279  0.0  0.0  35368  3276 ?        Ss   May20   0:01 /lib/systemd/systemd-journald
root       306  0.0  0.0  45956  5384 ?        Ss   May20   0:00 /lib/systemd/systemd-udevd
systemd+   703  0.0  0.0 100324  2532 ?        Ssl  May20   0:00 /lib/systemd/systemd-timesyncd
root       709  0.0  0.0  20100  2824 ?        Ss   May20   0:00 /lib/systemd/systemd-logind
root       716  0.0  0.0  29880  1564 ?        Ss   May20   0:00 /sbin/cgmanager -m name=systemd
message+   727  0.0  0.0  52848  5668 ?        Ss   May20   0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation

我读过SystemdForUpstartUsers 维基页面并确认软件包systemd-sysvubuntu-standard已安装,而未upstart-sysv 安装。因此我似乎拥有正确的软件包。我也在 Google 上搜索过这些错误消息(徒劳无功),但没有找到解决方案。

完整错误信息:

$ sudo systemctl disable puppet.service
Synchronizing state of puppet.service with SysV init with /lib/systemd/systemd-sysv-install...
Executing /lib/systemd/systemd-sysv-install disable puppet
insserv: warning: current start runlevel(s) (empty) of script `puppet' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `puppet' overrides LSB defaults (0 1 6).
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'screen-cleanup' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `screen-cleanup'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `screen-cleanup'
insserv: warning: current start runlevel(s) (empty) of script `puppet' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `puppet' overrides LSB defaults (0 1 6).
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'screen-cleanup' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `screen-cleanup'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `screen-cleanup'

任何帮助都值得感激!

更新于2016-05-24:

如果我删除相关/etc/init.d脚本(如上/etc/init.d/puppet例所示),错误消息就会消失。想必 systemd 正在使用/lib/systemd/system/puppet.service……?

相关内容