linux开启nscd服务缓存加速-DNS缓存

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/loophome/article/details/85102061

在我使用的阿里云主机上有观察到开启了一个服务nscd ,后来谷哥了下该服务的作用。了解到nscd会缓存三种服务passwd group hosts,所以它会记录三个库,分别对应源/etc/passwd, /etc/hosts 和 /etc/resolv.conf每个库保存两份缓存,一份是找到记录的,一份是没有找到记录的。每一种缓存都保存有生存时间(TTL)。其作用就是在本 当中增加cache ,加快如DNS的解析等的速度。

如果没有安装nscd,可以使用yum安装。

我们做微服务的时候,往往需要调用多个域的接口,如果没有使用nscd,就必须先请求内网dns获取到IP。这样往往导致性能下降。

一、nscd.conf配置(默认配置)

主要对hosts进行缓存

cat /etc/nscd.conf 
#logfile        /var/log/nscd.log
threads         6
max-threads     128
server-user     nscd
debug-level     5
paranoia        no
enable-cache    passwd      no
enable-cache    group       no
enable-cache    hosts       yes
positive-time-to-live   hosts   5
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

二、nscd操作

命令 说明
nscd -g 查询缓存配置,缓存情况
nscd -i [passwd|passwd|hosts] 清楚对应table的缓存
   

猜你喜欢

转载自blog.csdn.net/loophome/article/details/85102061