“nscd”服务说明

这是名称服务缓存守护进程(Name Service Cache Daemon)的缩写。
它负责运行程序的组和密码查找,然后缓存下一次查询的查找结果,这些服务在获取更改(如 NIS 或者 LDAP)时可能会遇到缓慢的情况。
如果我们正在运行这些服务,我们可能需要运行 nscd。

这个守护进程可以缓存名称服务、/etc/hosts、DNS、NIS、NIS+等的数据。
这只适用于本机本地用户,因为缓存是通过将函数封装在glibc中实现的,远程用户永远无法使用这个缓存.即使更改了原始 DNS 数据,更改缓存也需要时间,因此请小心使用此守护程序。

Linux 操作系统“nscd”服务
on  it road.com

配置

示例配置文件:

# nscd will run as "nscd" user and not as root.
        server-user             nscd
# nscd set no debug output. if level is higher than 0, nscd will create some debug output, the higher the level, the more output is produced
        debug-level             0
# disable paranoia mode, nscd will not restart itself periodically
        paranoia                no
# enables the specified service "passwd" cache
        enable-cache            passwd          yes
# Sets the TTL (time-to-live) for positive entries (successful queries) in the specified cache for "passwd" to 600 seconds
        positive-time-to-live   passwd          600
# Sets the TTL (time-to-live) for negative entries (unsuccessful queries) in  the  specified  cache for "passwd" to 20 seconds
        negative-time-to-live   passwd          20
# Sets the internal hash table size to 211
        suggested-size          passwd          211
# Enables checking the file belonging to the specified service "passwd" for changes
        check-files             passwd          yes
# Keep the content of the cache for service "passwd" over server restarts;
        persistent              passwd          yes
# The memory mapping of the nscd databases for service "passwd" is shared with the clients
        shared                  passwd          yes
# The maximum allowable size for the service "passwd" set to be 33554432 bytes
        max-db-size             passwd          33554432
# The .byname requests will add to passwd.byuid or group.bygid cache.
        auto-propagate          passwd          yes

服务控制

“chkconfig -list [service]”示例

# chkconfig --list nscd
nscd            0:off   1:off   2:off   3:off   4:off   5:off   6:off

可用的服务使用选项:

# service nscd
Usage: /etc/init.d/nscd {start|stop|status|restart|reload|condrestart}

启动服务:

# service nscd start
Starting nscd:                                             [  OK  ]

停止服务:

# service nscd stop
Stopping nscd:                                             [  OK  ]

检查服务状态:

# service nscd status
nscd (pid 15382) is running...

重启服务:

# service nscd restart
Stopping nscd:                                             [  OK  ]
Starting nscd:                                             [  OK  ]

重新加载服务重新读取配置文件:

# service nscd reload
Reloading nscd:                                            [  OK  ]

有条件重启服务:

# service nscd condrestart
Stopping nscd:                                             [  OK  ]
Starting nscd:                                             [  OK  ]

它运行哪些守护进程:/usr/sbin/nscd
它加载哪些模块:无

故障排除

有时重启、停止或者启动 NSCD 守护进程,它不会刷新它的缓存,我们需要使用以下方法显式刷新旧缓存:
CentOS/RHEL 7 之前:

# service nscd reload

CentOS/RHEL 7 之后:

# systemctl restart nscd
日期:2020-09-17 00:14:37 来源:oir作者:oir