Systemd

Postfix 服務已啟用,但不會在重新啟動時啟動

  • April 5, 2019

重啟系統postfix後服務不會啟動。我們正在使用基於 OpenSuse 12.1 的自定義 Linux 作業系統,最近驗證部門發現/var由於postfix.

那些郵件是誰發的?我們有一些應用程序在系統之間共享一些日誌。

我正在尋找不同類型的論壇以尋求我的答案,但沒有任何成功。

在 rebbot 之後:

$systemctl status postfix.service
postfix.service - Postfix Mail Transport Agent
         Loaded: loaded (/etc/systemd/system/postfix.service; enabled)
         Active: inactive (dead)
         CGroup: name=systemd:/system/postfix.service

我在這裡發現Postfix 不會在重新啟動時啟動,該問題可能與sendmail. 為了確保該sendmail程序與以下連結良好postfix

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

我也簽到,/var/log/messages沒有任何關於sendmail甚至postfix失敗的資訊。

讓我們啟動服務:

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

好的。重新啟動系統,服務變為inactive(dead)。回到/var/log我找到了這個文件mail.warn

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

我不知道這是否不能幫助解決我的問題。

額外資訊

文件內postfix.service

$ cat /etc/systemd/system/postfix.service
[Unit]
Description=Postfix Mail Transport Agent
Requires=var-run.mount nss-lookup.target network.target remote-fs.target syslog.target time-sync.target
After=var-run.mount nss-lookup.target network.target remote-fs.target syslog.target time-sync.target
After=amavis.service mysql.service cyrus.service ldap.service openslp.service ypbind.service
Before=mail-transfer-agent.target
Conflicts=sendmail.service exim.service

[Service]
Type=forking
PIDFile=/var/spool/postfix/pid/master.pid
ExecStartPre=-/bin/echo 'Starting mail service (Postfix)'
EnvironmentFile=-/etc/sysconfig/postfix
ExecStartPre=/etc/postfix/system/update_chroot
ExecStart=/usr/sbin/postfix start
ExecStartPost=/etc/postfix/system/wait_qmgr 60
ExecStartPost=/etc/postfix/system/cond_slp register
ExecReload=/usr/sbin/postfix reload
ExecReload=/usr/sbin/postfix flush
ExecStop=/usr/sbin/postfix stop
ExecStopPost=/etc/postfix/system/cond_slp deregister

[Install]
WantedBy=multi-user.target

重新啟動後列出所有服務而不啟動postfix服務。

$systemctl list-unit-files --type=service
...
klog.service              disabled
klogd.service             masked
ldconfig.service          masked
loadmodules.service       masked
local.service             static
localfs.service           static
openhpid.service          enabled
postfix.service           enabled
postgresql.service        static
poweroff.service          static
proc.service              masked
...

由於我們在基於 OpenSuse 12.1 的作業系統上執行,journalctl因此尚未引入systemd

更新

設置LogLevel=debug/etc/systemd/system.conf,我能夠獲得與此問題相關的更多數據。在/var/log/messages/我發現這個:

Jan 31 19:17:00 msx kernel:   10.111126] systemd[1]: -.mount changed dead -> mounted
Jan 31 19:17:00 msx kernel:   10.111147] systemd[1]: Activating default unit: default.target
Jan 31 19:17:00 msx kernel:   10.111153] systemd[1]: Trying to enqueue job multi-user.target/start/replace
Jan 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.
Jan 31 19:17:00 msx kernel:   10.111276] systemd[1]: Found ordering cycle on lwresd.service/start
Jan 31 19:17:00 msx kernel:   10.111279] systemd[1]: Walked on cycle path to nss-lookup.target/start
Jan 31 19:17:00 msx kernel:   10.111281] systemd[1]: Walked on cycle path to lwresd.service/start
Jan 31 19:17:00 msx kernel:   10.111284] systemd[1]: Breaking ordering cycle by deleting job nss-lookup.target/start
Jan 31 19:17:00 msx kernel:   10.111286] systemd[1]: Deleting job postfix.service/start as dependency of job nss-lookup.target/start

我什至不知道什麼 nss-lookup什麼。

nss-lookup.target是可選的systemd特殊目標之一。它本質上是啟動過程中的一個虛擬里程碑。具體來說,任何影響 DNS 查找的系統服務(lwresd可能會這樣)都應該在他們的.service文件中指定他們需要在之前 nss-lookup.target啟動:

[Unit]
Wants=nss-lookup.target
Before=nss-lookup.target

…並且任何需要 DNS 解析在啟動之前完全正常工作的服務都可以簡單地指定為:

[Unit]
After=nss-lookup.target

可能是lwresd軟體包沒有完全遵循此方案,或者您的自定義發行版具有較舊版本,systemd有理由使用Requires=而不是Wants=目前推薦的方式。

當 systemd 在其配置中檢測到排序衝突(“排序循環”)時,它會以一種非常機械的方式解決它,這在總體方案中並不總是最優的。在這種情況下,問題在於 和 之間的排序lwresdnss-lookup.target但 Postfix 在此過程中被跳過作為附帶損害。

由於nss-lookup.target是可選的,因此將其設置Requires=為 Postfix 的依賴項太強了,可能會導致問題……就像你所擁有的一樣。

引用自:https://unix.stackexchange.com/questions/350633