Linux SendMail服务启动慢总结

发表于:2015-8-14 09:43

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:潇湘隐者    来源:51Testing软件测试网采编

#
Linux
分享:
  在 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]#
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号