linux系統dns緩存服務nscd

衆所周知,Linux本身是不帶DNS緩存的。

可以安裝nscd來開啓linux系統dns緩存。

1.安裝:

yum -y install nscd  

2.修改配置文件:

vim /etc/nscd.conf    

        logfile                 /var/log/nscd.log

        threads                 4

        max-threads             32

        server-user             nscd

        debug-level             0

        reload-count            5

        paranoia                no

        restart-interval        3600

        enable-cache            hosts           yes

        positive-time-to-live   hosts           3600

        negative-time-to-live   hosts           20

        suggested-size          hosts           211

        check-files             hosts           yes

        persistent              hosts           yes

        shared                  hosts           yes

        max-db-size             hosts           33554432

3.重啓nscd服務。

/etc/init.d/nscd restart


nscd緩存三種服務passwd group hosts,所以它會記錄三個庫,分別對應源/etc/passwd, /etc/hosts 和 /etc/resolv.conf每個庫保存兩份緩存,一份是找到記錄的,一份是沒有找到記錄的。每一種緩存都保存有生存時間(TTL).


開啓 、停止、 重啓服務

sevices nscd start | stop | restart


緩存DB文件在/var/db/nscd下


nscd -g  查看統計信息


清除緩存

nscd -i passwd

nscd -i group

nscd -i hosts

補充:開啓 NSCD 緩存服務以加快 DNS 解析速度


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章