Postfix 服务已启用,但重启后无法启动

SAN*_*xis 5 opensuse systemd services postfix

重新启动系统后该postfix服务将无法启动。我们正在使用基于 OpenSuse 12.1 的自定义 Linux 操作系统,最近验证部门发现/var由于postfix.

\n\n

谁发送这些邮件?我们有一些应用程序在系统之间共享一些日志。

\n\n

我正在寻找不同类型的论坛来寻找答案,但没有成功。

\n\n

雷伯特之后:

\n\n
$systemctl status postfix.service\npostfix.service - Postfix Mail Transport Agent\n          Loaded: loaded (/etc/systemd/system/postfix.service; enabled)\n          Active: inactive (dead)\n          CGroup: name=systemd:/system/postfix.service\n
Run Code Online (Sandbox Code Playgroud)\n\n

我在这里发现Postfix 不会在重新启动时启动,问题可能是与sendmail. 为了确保该sendmail程序与以下内容良好链接postfix

\n\n
$ ldd /usr/sbin/sendmail\n        linux-vdso.so.1 =>  (0x00007fffa25ff000)\n        libpostfix-global.so.1 => /usr/lib64/libpostfix-global.so.1 (0x00007fdb174d2000)\n        libpostfix-util.so.1 => /usr/lib64/libpostfix-util.so.1 (0x00007fdb1729a000)\n        libc.so.6 => /lib64/libc.so.6 (0x00007fdb16f0a000)\n        libdl.so.2 => /lib64/libdl.so.2 (0x00007fdb16d06000)\n        libdb-4.8.so => /usr/lib64/libdb-4.8.so (0x00007fdb1698a000)\n        libnsl.so.1 => /lib64/libnsl.so.1 (0x00007fdb16772000)\n        /lib64/ld-linux-x86-64.so.2 (0x00007fdb1770b000)\n        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fdb16555000)\n
Run Code Online (Sandbox Code Playgroud)\n\n

我也检查了一下/var/log/messages,没有任何有关sendmail甚至postfix失败的信息。

\n\n

让我们启动服务:

\n\n
$ systemctl start postfix.service\n$ systemctl status postfix.service\npostfix.service - Postfix Mail Transport Agent\n          Loaded: loaded (/etc/systemd/system/postfix.service; enabled)\n          Active: active (running) since Sat, 28 Jan 2017 21:49:37 +0300; 41s ago\n         Process: 3450 ExecStartPost=/etc/postfix/system/cond_slp register (code=exited, status=0/SUCCESS)\n         Process: 3444 ExecStartPost=/etc/postfix/system/wait_qmgr 60 (code=exited, status=0/SUCCESS)\n         Process: 3368 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)\n         Process: 3366 ExecStartPre=/etc/postfix/system/update_chroot (code=exited, status=0/SUCCESS)\n         Process: 3363 ExecStartPre=/bin/echo Starting mail service (Postfix) (code=exited, status=0/SUCCESS)\n        Main PID: 3443 (master)\n          CGroup: name=systemd:/system/postfix.service\n                  \xe2\x94\x9c 3443 /usr/lib/postfix/master\n                  \xe2\x94\x9c 3445 pickup -l -t fifo -u\n                  \xe2\x94\x9c 3446 qmgr -l -t fifo -u\n                  \xe2\x94\x9c 3447 cleanup -z -t unix -u\n                  \xe2\x94\x9c 3466 trivial-rewrite -n rewrite -t unix -u\n                  \xe2\x94\x9c 3467 local -t unix\n                  \xe2\x94\x9c 3468 local -t unix\n                  \xe2\x94\x94 3469 local -t unix\n
Run Code Online (Sandbox Code Playgroud)\n\n

好的。重新启动系统,服务转为非活动(死亡)状态。返回/var/log我发现这个文件mail.warn

\n\n
$ cat mail.info\nJan 28 03:13:55 msx postfix/postfix-script[2527]: warning: not owned by group maildrop: /usr/sbin/postqueue\nJan 28 03:13:55 msx postfix/postfix-script[2528]: warning: not owned by group maildrop: /usr/sbin/postdrop\nJan 28 03:13:55 msx postfix/postfix-script[2530]: warning: not set-gid or not owner+group+world executable: /usr/sbin/postqueue\nJan 28 03:13:55 msx postfix/postfix-script[2531]: warning: not set-gid or not owner+group+world executable: /usr/sbin/postdrop\nJan 28 21:49:37 msx postfix/postfix-script[3430]: warning: not owned by group maildrop: /usr/sbin/postqueue\nJan 28 21:49:37 msx postfix/postfix-script[3431]: warning: not owned by group maildrop: /usr/sbin/postdrop\nJan 28 21:49:37 msx postfix/postfix-script[3434]: warning: not set-gid or not owner+group+world executable: /usr/sbin/postqueue\nJan 28 21:49:37 msx postfix/postfix-script[3435]: warning: not set-gid or not owner+group+world executable: /usr/sbin/postdrop\n
Run Code Online (Sandbox Code Playgroud)\n\n

不知道这是否能帮助解决我的问题。

\n\n

额外信息

\n\n

文件内postfix.service

\n\n
$ cat /etc/systemd/system/postfix.service\n[Unit]\nDescription=Postfix Mail Transport Agent\nRequires=var-run.mount nss-lookup.target network.target remote-fs.target syslog.target time-sync.target\nAfter=var-run.mount nss-lookup.target network.target remote-fs.target syslog.target time-sync.target\nAfter=amavis.service mysql.service cyrus.service ldap.service openslp.service ypbind.service\nBefore=mail-transfer-agent.target\nConflicts=sendmail.service exim.service\n\n[Service]\nType=forking\nPIDFile=/var/spool/postfix/pid/master.pid\nExecStartPre=-/bin/echo \'Starting mail service (Postfix)\'\nEnvironmentFile=-/etc/sysconfig/postfix\nExecStartPre=/etc/postfix/system/update_chroot\nExecStart=/usr/sbin/postfix start\nExecStartPost=/etc/postfix/system/wait_qmgr 60\nExecStartPost=/etc/postfix/system/cond_slp register\nExecReload=/usr/sbin/postfix reload\nExecReload=/usr/sbin/postfix flush\nExecStop=/usr/sbin/postfix stop\nExecStopPost=/etc/postfix/system/cond_slp deregister\n\n[Install]\nWantedBy=multi-user.target\n
Run Code Online (Sandbox Code Playgroud)\n\n

重新启动后列出所有服务而不启动postfix服务。

\n\n
$systemctl list-unit-files --type=service\n...\nklog.service              disabled\nklogd.service             masked\nldconfig.service          masked\nloadmodules.service       masked\nlocal.service             static\nlocalfs.service           static\nopenhpid.service          enabled\npostfix.service           enabled\npostgresql.service        static\npoweroff.service          static\nproc.service              masked\n...\n
Run Code Online (Sandbox Code Playgroud)\n\n

由于我们运行在基于 OpenSuse 12.1 的操作系统上,journalctl因此尚未引入systemd

\n\n

更新

\n\n

LogLevel=debug设置后/etc/systemd/system.conf,我能够获得更多与此问题相关的数据。在/var/log/messages/我发现这个:

\n\n
Jan 31 19:17:00 msx kernel:   10.111126] systemd[1]: -.mount changed dead -> mounted\nJan 31 19:17:00 msx kernel:   10.111147] systemd[1]: Activating default unit: default.target\nJan 31 19:17:00 msx kernel:   10.111153] systemd[1]: Trying to enqueue job multi-user.target/start/replace\nJan 31 19:17:00 msx kernel:   10.111204] systemd[1]: Cannot add dependency job for unit hpiwdt.service, ignoring: Unit hpiwdt.service failed to load: No such file or directory. See system logs and \'systemctl status hpiwdt.service\' for details.\nJan 31 19:17:00 msx kernel:   10.111276] systemd[1]: Found ordering cycle on lwresd.service/start\nJan 31 19:17:00 msx kernel:   10.111279] systemd[1]: Walked on cycle path to nss-lookup.target/start\nJan 31 19:17:00 msx kernel:   10.111281] systemd[1]: Walked on cycle path to lwresd.service/start\nJan 31 19:17:00 msx kernel:   10.111284] systemd[1]: Breaking ordering cycle by deleting job nss-lookup.target/start\nJan 31 19:17:00 msx kernel:   10.111286] systemd[1]: Deleting job postfix.service/start as dependency of job nss-lookup.target/start\n
Run Code Online (Sandbox Code Playgroud)\n\n

我什至不知道什么做什么 nss-lookup

\n

tel*_*coM 2

nss-lookup.target是可选的特殊目标之一systemd。它本质上充当启动过程中的虚拟里程碑。具体来说,任何影响 DNS 查找的系统服务(lwresd可能是这样)都应该在其.service文件中指定它们需要在以下时间之前 nss-lookup.target启动:

[Unit]
Wants=nss-lookup.target
Before=nss-lookup.target
Run Code Online (Sandbox Code Playgroud)

...任何需要 DNS 解析才能启动的服务都可以简单地指定为:

[Unit]
After=nss-lookup.target
Run Code Online (Sandbox Code Playgroud)

可能是该lwresd软件包没有完全遵循此方案,或者您的自定义发行版具有较旧的版本,systemd其中有某种原因需要使用Requires=而不是Wants=当前推荐的方式。

当 systemd 在其配置中检测到排序冲突(“排序周期”)时,它会以非常机械的方式解决它,这在总体方案中并不总是最佳的。在本例中,问题在于lwresd和之间的排序nss-lookup.target,但 Postfix 在该过程中被跳过作为附带损害。

由于nss-lookup.target是可选的,因此将其设置为Requires=Postfix 的依赖项太强并且可能会导致问题......与您所遇到的完全一样。