正如标题所述,postfix
重新启动系统后服务将无法启动。我们正在使用基于 OpenSuse 12.1 的自定义 Linux 操作系统,最近验证部门发现/var
由于 maildrop 队列中未发送的邮件,存储库变得越来越大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
好。重启系统,服务变为不活跃(死亡). 返回到/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
...
更新
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
。如果有人有任何想法。谢谢。
答案1
除此之外,openSUSE 12.1 有点旧(2013 年发布),并且不再接收更新,所以我会考虑使用更新的操作系统。
您的日志显示了一些权限问题(postfix 有几个用于非特权操作的帐户/组,因此可能会有点混乱):
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
在较新的 SUSE 系统上,postfix 的权限如下:
> sudo cat /etc/permissions.d/postfix
/usr/sbin/sendmail root:root 0755
/etc/postfix/sasl_passwd root:root 0600
/etc/postfix/sasl_passwd.db root:root 0600
/usr/sbin/postqueue root:maildrop 2755
/usr/sbin/postdrop root:maildrop 2755
应用这些权限应该可以解决日志中看到的两个基本问题,即 postdrop 和 postqueue 的所有权和模式不正确。
您可以运行sudo chkstat --warn --system
来检查可能需要修复哪些权限,如果一切正常,则通过运行让它执行操作sudo chkstat --system --set
答案2
首先,添加LogLevel=debug
可/etc/systemd/system.conf
提供有用的日志,以了解启动运行时服务上真正发生的情况。正如我在更新的问题中提到的, 存在与 的顺序冲突。通过直接nss-lookup.target
删除两个变量中的,系统能够在启动过程中启动。nss-lookup.target
/etc/systemd/system/postfix.service
[Requires]
[After]
postfix
希望这能有所帮助。
谢谢
答案3
Sendmail 和 Postfix 之间可能存在冲突。如果您计划使用 Postfix 作为主要电子邮件应用程序,请确保重启后 Sendmail 未运行。这两个应用程序都已配置为在重启时关闭任何冲突的应用程序,从而避免冲突。
答案4
我解决这个问题的方法是先检查谁在打开端口 25(如果端口 25 确实打开的话)。当然,他们中只有一个人一次可以使用端口 25。你可以试试ss- 4tln -o state LISTENINING '( sport = :25 )'