在 CentOS release 6.6 上啟動(dòng)sendmail服務(wù)時(shí)發(fā)現(xiàn)服務(wù)啟動(dòng)過程非常慢,基本上要耗費(fèi)3分多鐘。有點(diǎn)納悶:什么原因?qū)е聅endmail啟動(dòng)這么慢?搜索了這方面的一些資料,結(jié)合自己的理解,把它梳理一遍。權(quán)當(dāng)筆記。
[root@MySQL-T01 bin]# service sendmail stop
Shutting down sm-client: [ OK ]
Shutting down sendmail: [ OK ]
[root@MySQL-T01 bin]# date
Wed Aug 5 09:11:00 UTC 2015
[root@MySQL-T01 bin]# service sendmail start
Starting sendmail: [ OK ]
Starting sm-client: [ OK ]
[root@MySQL-T01 bin]# date
Wed Aug 5 09:14:53 UTC 2015
如上所示,sendmail服務(wù)的啟動(dòng)整整需要花費(fèi)3分多鐘。因?yàn)镾tarting sendmail、Starting sm-client這兩步check需要查詢你設(shè)置的主機(jī)名的A記錄或反向域名記錄,由于全球9臺(tái)DNS根系統(tǒng)都在美國,這個(gè)時(shí)候會(huì)去查詢本機(jī)主機(jī)名對(duì)應(yīng)的dns A記錄。查詢可能會(huì)非常的慢.
通常的域名解析是指A記錄解析,即主機(jī)記錄解析,就是指把域名解析到虛擬主機(jī)的過程;又稱ip指向,用戶可以在此設(shè)置子域名并指向到自己的目標(biāo)主機(jī)地址上,從而實(shí)現(xiàn)通過域名找到服務(wù)器。
解決方法
讓sendmial繞過查詢遠(yuǎn)程主機(jī),這里給出一種最簡(jiǎn)單的方法,給主機(jī)設(shè)置一個(gè)別名。
/etc/hosts原始配置
[root@MySQL-T01 bin]# more /etc/hosts
10.20.251.45 MySQL-T01 localhost
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
/etc/hosts修改配置
[root@MySQL-T01 bin]# vi /etc/hosts
10.20.251.45 MySQL-T01 localhost
127.0.0.1 localhost localhost.localdomain MySQL-T01
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
"/etc/hosts" 3L, 170C written
修改完成后,關(guān)閉sendmail服務(wù),啟動(dòng)sendmail服務(wù)非???,只要一兩秒的樣子。
[root@MySQL-T01 bin]# service sendmail stop
Shutting down sm-client: [ OK ]
Shutting down sendmail: [ OK ]
[root@MySQL-T01 bin]# service sendmail start
Starting sendmail: [ OK ]
Starting sm-client: [ OK ]
[root@MySQL-T01 bin]#
參考資料:
http://blog.sina.com.cn/s/blog_4560b80b0100mns5.html
http://www.slyar.com/blog/linux-sendmail-sm-client.html
新聞熱點(diǎn)
疑難解答
圖片精選