djbdns 真是个好东西,困扰好久的sendmail发信速度慢的问题解决!

引用本文请注明出处:Just Do IT (http://www.toplee.com) < Michael Lee @ toplee.com >

前几天服务器更换了电信的ip和dns之后,速度有了很大提高,系统发信的速度也基本达到了正常可以接受的水平,但是如果要应付大量的邮件列表功能,还是感觉有些吃力,于是考虑进一步提高dns解析速度,因为sendmail响应慢很大程度跟dns反向解析解析有关,在网上查了很多资料都提到受sendmail发信慢的困扰,但是都没有看到好的解决办法。

偶然间从freebsd的ports/dns/下看到了djbdns这个包,一查资料发现有个dnscache功能,于是决定一试,没想效果出奇的好,非常值得推荐给大家!

下面是我安装过程,和大家分享!

全部都是使用root用户操作下面的命令!

[coolcode]
#cd /usr/ports/dns/djbdns
#make install clean
#mkdir /var/service
#csh (或者exit退出再登陆,或者运行bash也可以)
#dnscache-conf nobody nobody /var/service/dnscache 127.0.0.1
#vi /etc/rc.conf 里加入 svscan_enable=”YES”
#/usr/local/etc/rc.d/svscan.sh start 启动服务,完成安装
下面检查服务启动情况
#netstat -anl |grep LISTEN
看看里面是否有53端口的监听服务,如果有就ok了
接着修改/etc/reslove.conf文件,把127.0.0.1加入到第一行,如下
nameserver 127.0.0.1
nameserver xx.xx.xx.xx (其他的公网dns)

这时测试一下效果
dig www.sina.com.cn
你会发现可能第一次稍微时间长一点,第二次反应时间都基本是0.000msec或者0.001msec,这就是取到了本地的缓存,效果好得不行!

[/coolcode]

接着测试了sendmail的大量并发发信,结果非常的喜人,完全能满足中等网站的并发业务处理了,朋友们可以自己测试一下:)

djbdns其他的功能我还没有研究到,欢迎大家和我一起学习和交流!

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
7 Responses
  1. FreeBSD-Lover says:

    用BIND可以吗?

  2. Michael says:

    bind也是可以的,届时设置您的reslove.conf文件,把nameserver第一个设置为您的bind地址,bind相对复杂一些,在缓存方面没有djbdns轻量级和高效。

  3. apple says:

    对外查询是在本地打开随机的UDP端口连接外部的53端口吗?如果是,IPFW的规则要怎么写?

  4. Michael says:

    往外连接你还需要限制? 你可以指定协议UDP到 target的port是53的都开放,具体书写语句看ipfw的man吧。理论上这个规则是默认都会打开的,要不你的机器怎么做dns解析.

  5. axpwx says:

    怎么才可以清空dnscache的缓存呢?找了好久,没找到办法.

  6. Michael says:

    最笨的办法: 删除目录,dnscache-conf重建一下

  7. axpwx says:

    Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image