Add a record in the/etc/hosts file, found that the ping host name after the resolution does not take effect, that is, the result of the ping is not the same as the IP written in the hosts.
To view the ping command execution process through Strace:
Strace-f-f-o/tmp/ping.txt Ping bi.v.addev.com
You can see that the entire ping process is first connected to the local NSCD cache, which cleans up the NSCD cache (Nscd-i hosts) and discovers that the hosts bound IP immediately takes effect.
View NSCD profile:/etc/nscd.conf learned that NSCD will cache three services passwd the group hosts, so it will record three libraries, corresponding to the source/etc/passwd,/etc/hosts and/etc/, respectively Resolv.conf Each library holds two copies of the cache, one for the record, and one for the record. Each cache is saved with a time-to-Live (TTL). Its role is to increase the cache in this, speed up such as DNS resolution and so on.
Enable-cache hosts Yes
The local hosts cache is turned on
# logfile /var/log/nscd.log# threads 4# max-threads 32 server-user nscd# stat-user somebody debug-level 0# reload-count 5 paranoia no# restart-interval 3600 enable-cache passwd yes positive-time-to-live passwd 600 negative-time-to-live passwd 20 suggested-size passwd 211 check-files passwd yes persistent passwd yes shared passwd yes max-db-size passwd 33554432 auto-propagate passwd yes enable-cache group yes positive-time-to-live group 3600 negative-time-to-live group 60 suggested-size group 211 check-files group yes persistent group yes shared group yes max-db-size group 33554432 auto-propagate group yes 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 enable-cache services yes positive-time-to-live services 28800 negative-time-to-live services 20 suggested-size services 211 check-files services yes persistent services yes shared services yes max-db-size services 33554432
Description
Server-user User
If this option is set, NSCD will run as the user, not as root. This option is ignored if each user uses a separate cache (-s parameter).
Enable-cache Service <yes|no>
Enables or disables the established service cache.
Positive-time-to-live Service Value
Sets the TTL (Time-to-live) for items in the specified cache for the service (successful requests). Value is in seconds. A larger value increases the cache hit ratio to reduce the average response time, but increases the consistency of the cache.
Negative-time-to-live Service Value
Sets the TTL (Time to live) of items (failed requests) that the service has negative in the specified cache. Value is in seconds. If there are files owned by a UID (user ID) that is not in the system database (for example, when the Linux kernel source code is unpacked as root), the performance will be significantly improved, and a smaller value should be maintained to reduce the cache consistency problem.
Suggested-size Service Value
This is the size of the internal hash table, and value should maintain a prime number to achieve the optimization effect.
Check-files Service <yes|no>
Enables or disables checking for changes to files belonging to the specified service. These files are/etc/passwd,/etc/group, and/etc/hosts.
Clear Cache
Nscd-i passwd
Nscd-i Group
Nscd-i hosts
This article from "Ops said: from rookie to veteran" blog, please be sure to keep this source http://liuqunying.blog.51cto.com/3984207/1669889
NSCD DNS cache changes caused by hosts not effective in time