2013-11-06
前言:分享 mail server 架設,以及 troubleshooting 經驗。
想架 Mail Server,CentOS 上最有名的首推 sendmail,yum 應該有支援吧
[root@localhost html]# yum list | grep sendmail
sendmail.x86_64 8.14.4-8.el6 base
sendmail-cf.noarch 8.14.4-8.el6 base
sendmail-devel.i686 8.14.4-8.el6 base
sendmail-devel.x86_64 8.14.4-8.el6 base
sendmail-doc.noarch 8.14.4-8.el6 base
sendmail-milter.i686 8.14.4-8.el6 base
sendmail-milter.x86_64 8.14.4-8.el6 base
安裝 sendmail
[root@localhost html]# yum -y install sendmail
設定 reboot 後也會自動啟動 sendmail
[root@localhost html]# chkconfig sendmail on
檢查一下
[root@localhost html]# chkconfig --list | grep sendmail
sendmail 0:off 1:off 2:on 3:on 4:on 5:on 6:off
立刻啟動 sendmail
[root@localhost html]# service sendmail start
Starting sendmail: [ OK ]
Starting sm-client: [ OK ]
檢查
[root@localhost html]# service sendmail status
sendmail dead but subsys locked
sm-client (pid 8504) is running...
居然發生 sendmail dead but subsys locked
檢查一下執行情況
[root@localhost html]# ps aux | grep sendmail
smmsp 8504 0.0 0.2 76092 2060 ? Ss 08:57 0:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
root 8533 0.0 0.0 103236 860 pts/1 S+ 08:59 0:00 grep sendmail
檢查一下有哪些 lock file
[root@localhost ~]# ls /var/lock/subsys/
abrt-ccpp acpid auditd blk-availability crond haldaemon iptables lvm2-monitor netfs NetworkManager rpcbind rpc.statd sendmail sshd
abrtd atd autofs certmonger cups ip6tables local messagebus network postfix rpc.idmapd rsyslog sm-client udev-post
刪除 sendmail 和 sm-client 兩個 lock file
[root@localhost ~]# rm -fr /var/lock/subsys/sendmail /var/lock/subsys/sm-client
[root@localhost ~]# ls /var/lock/subsys/
abrt-ccpp acpid auditd blk-availability crond haldaemon iptables lvm2-monitor netfs NetworkManager rpcbind rpc.statd sshd
abrtd atd autofs certmonger cups ip6tables local messagebus network postfix rpc.idmapd rsyslog udev-post
再重新啟動一次
[root@localhost ~]# service sendmail restart
Shutting down sm-client: [ OK ]
Shutting down sendmail: [FAILED]
Starting sendmail: [ OK ]
Starting sm-client: [ OK ]
再次檢查,依然不行
[root@localhost ~]# service sendmail status
sendmail dead but subsys locked
sm-client (pid 28584) is running...
該不會...另一套著名的 mail server 軟體 postfix 已經安裝啟動了?
(下)檢查一下是否安裝 postfix,果然安裝了
[root@localhost html]# yum list | grep postfix
postfix.x86_64 2:2.6.6-2.2.el6_1 @anaconda-CentOS-201303020151.x86_64/6.4
postfix-perl-scripts.x86_64 2:2.6.6-2.2.el6_1 base
(下)檢查一下,postfix 果然啟動了
[root@localhost ~]# ps aux | grep postfix
root 1750 0.0 0.3 78720 3268 ? Ss 10:36 0:00 /usr/libexec/postfix/master
postfix 1757 0.0 0.3 78968 3144 ? S 10:36 0:00 qmgr -l -t fifo -u
postfix 28191 0.0 0.3 78800 3236 ? S 12:20 0:00 pickup -l -t fifo -u
root 28601 0.0 0.0 103248 836 pts/1 S+ 13:59 0:00 grep postfix
**********************************************************
(下)因為想用 sendmail,準備把 postfix 停掉
PS:system-switch-mail 在 CentOS 6.x 不再提供
立刻停掉 postfix
[root@localhost ~]# service postfix stop
Shutting down postfix: [ OK ]
檢查一下狀態
[root@localhost ~]# service postfix status
master is stopped
檢查一下是否還有 postfix 程序仍在執行中
[root@localhost ~]# ps aux | grep postfix
root 28672 0.0 0.0 103244 832 pts/1 S+ 14:14 0:00 grep postfix
(下)檢查一下是否有設定 postfix 在 reboot 後自動啟動
[root@localhost html]# chkconfig --list | grep postfix
沒有出現類似 postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off 的一行
chkconfig 居然沒有 postfix 這項...
(下)替 chkconfig 增加一項 postfix
[root@localhost init.d]# chkconfig --add postfix
(下)檢查一下是否有設定 postfix 在 reboot 後自動啟動
[root@localhost init.d]# chkconfig --list | grep postfix
postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off
(下)關閉 reboot 後自動啟動 postfix
[root@localhost ~]# chkconfig postfix off
(下)檢查,確認都 off 了
[root@localhost ~]# chkconfig --list | grep postfix
postfix 0:off 1:off 2:off 3:off 4:off 5:off 6:off
*********************************
(下) 重新啟動 sendmail
[root@localhost init.d]# service sendmail restart
Shutting down sm-client: [ OK ]
Shutting down sendmail: [FAILED]
Starting sendmail: [ OK ]
Starting sm-client: [ OK ]
(下) 檢查 sendmail 狀態,都是 running 了
[root@localhost ~]# service sendmail status
sendmail (pid 28729) is running...
sm-client (pid 28738) is running...
(下)檢查 sendmail 執行程序,比之前多了 sendmail: accepting connections
[root@localhost ~]# ps aux | grep sendmail
root 28729 0.0 0.2 90868 2384 ? Ss 14:20 0:00 sendmail: accepting connections
smmsp 28738 0.0 0.2 76080 2048 ? Ss 14:20 0:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
root 28753 0.0 0.0 103244 832 pts/1 S+ 14:20 0:00 grep sendmail
(下) 設定 reboot 後仍會自動啟動 sendmail
[root@localhost ~]# chkconfig sendmail on
(下) 檢查,確定有 on 了
[root@localhost ~]# chkconfig --list | grep sendmail
sendmail 0:off 1:off 2:on 3:on 4:on 5:on 6:off
一些重要目錄和檔案說明:
設定檔案:Postfix放在/var/postfix 目錄,Sendmail放在 /etc/mail 目錄,最重要的是 sendmail.cf
等待寄出信件目錄:Postfix放在/var/spool/postfix/active目錄,Sendmail放在 /var/spool/mqueue目錄
有問題信件:Postfix放在/var/spool/postfix/defer和/var/spool/postfix/deferred目錄,Sendmail放在 /var/spool/mqueue目錄
收到的信件(與退信):放在 /var/spool/mail 目錄,如果龐大,考慮刪除 (和 /var/mail 會指向 /var/spool/mail 目錄,故看到會相同 )
信件Log:不管Sendmail或Postfix都是/var/log/maillog、/var/log/maillog.1、/var/log/maillog.2、/var/log/maillog.3、/var/log/maillog.4,每個檔案放一星期資料,最新的是maillog
sendmail dead but subsys locked 不一定都是上面碰到的情況,不過這是一種情況,僅供參考。
(完)
相關
[研究] php-pear-Mail 安裝(CentOS 6.4 x64)
http://shaurong.blogspot.tw/2013/11/php-pear-mail-centos-64-x64.html
沒有留言:
張貼留言