Linux SendMail服务启动慢总结

在 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]# 

 

参考资料:

http://blog.sina.com.cn/s/blog_4560b80b0100mns5.html

http://www.slyar.com/blog/linux-sendmail-sm-client.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值