博客
关于我
linux缓存nscd
阅读量:797 次
发布时间:2023-02-05

本文共 942 字,大约阅读时间需要 3 分钟。

安装nscd缓存解析器是提升Linux系统性能的重要方法之一。以下是手动安装和配置nscd的完整指南。

1. 安装nscd

在Linux系统中安装nscd工具,可以通过以下命令实现:

yum -y install nscd

2. 配置nscd

配置nscd涉及修改系统配置文件

/etc/nscd.conf

3. 缓存位置

nscd默认将缓存文件存放在

/var/db/nscd

4. 查看和清除缓存

为了确保缓存有效,可以使用nscd命令查看统计信息:

nscd -g

清除缓存时,可以使用以下命令:

nscd -i passwd/group/hosts

然后重启或重新加载nscd服务:

service nscd restart

service nscd reload

5. nscd缓存机制

nscd是一个智能的缓存解析器,支持多种服务缓存,如passwd、group、hosts等。这些缓存分别对应以下文件:

/etc/passwd

/etc/hosts

/etc/resolv.conf

nscd为每个缓存库创建两份缓存:一份用于存储找到记录的信息,另一份用于存储未找到记录的信息。每条缓存记录都带有生存时间(TTL)限制。

6. 常见问题与解决方法

在实际应用中,可能会遇到nscd命中率为零的情况。这种现象通常由以下原因引起:

许多Linux服务直接访问缓存文件,而非通过nscd解析。这种方式虽然性能更优,但无法统计缓存命中率。

解决方法是关闭nscd的共享属性:

修改配置文件

/etc/nscd.conf

shared=caches

改为

shared=0

这样可以确保服务直接访问文件时不会影响nscd的缓存机制。

参考资料:

1. [http://octopresszhangyu.herokuapp.com/blog/2015/06/19/nscd/](http://octopresszhangyu.herokuapp.com/blog/2015/06/19/nscd/)

2. [https://www.hi-linux.com/posts/9461.html](https://www.hi-linux.com/posts/9461.html)

转载地址:http://xlkfk.baihongyu.com/

你可能感兴趣的文章
NN&DL4.7 Parameters vs Hyperparameters
查看>>
NN&DL4.8 What does this have to do with the brain?
查看>>
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>
No module named 'pandads'
查看>>
No module named cv2
查看>>
No module named tensorboard.main在安装tensorboardX的时候遇到的问题
查看>>
No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
查看>>
No new migrations found. Your system is up-to-date.
查看>>