centos sendmail 启动慢

from:http://www.cnblogs.com/kerrycode/p/4717498.html

在 CentOS release 6.6 上启动sendmail服务时发现服务启动过程非常慢,基本上要耗费3分多钟。有点纳闷:什么原因导致sendmail启动这么慢?搜索了这方面的一些资料,结合自己的理解,把它梳理一遍。权当笔记。

[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服务的启动整整需要花费3分多钟。因为Starting sendmail、Starting sm-client这两步check需要查询你设置的主机名的A记录或反向域名记录,由于全球9台DNS根系统都在美国,这个时候会去查询本机主机名对应的dns A记录。查询可能会非常的慢.

通常的域名解析是指A记录解析,即主机记录解析,就是指把域名解析到虚拟主机的过程;又称IP指向,用户可以在此设置子域名并指向到自己的目标主机地址上,从而实现通过域名找到服务器。

解决方法

让sendmial绕过查询远程主机,这里给出一种最简单的方法,给主机设置一个别名。

/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

修改完成后,关闭sendmail服务,启动sendmail服务非常快,只要一两秒的样子。

[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]#
原文地址:https://www.cnblogs.com/buxizhizhoum/p/7070987.html