2

I'm trying to troubleshoot an issue on a MediaTemple server (running CentOS5) where the DNS cache has grown stale - I think because nscd has crashed. I've tried restarting nscd:

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

This makes sense since I believe nscd has crashed so it shouldn't already be running, but When I view the status of nscd:

# service nscd status
nscd dead but subsys locked

And ps -A returns no processes related to nscd (I assume because it's dead). I've edited /etc/nscd.conf and uncommented the line that defines the location for the log file. It created the file but it never writes anything to it.

I tried looking at the init script but found that it's no help since the script thinks everything is running fine - the service returns that it started up correctly.

How do I 'unlock' the subsys that nscd is complaining about?

EEAA
  • 108,414
  • 18
  • 172
  • 242
Phunt
  • 45
  • 1
  • 2
  • 6
  • Duplicates ["What does ' dead but subsys locked' mean?"](http://serverfault.com/questions/26276/). – JdeBP Jun 14 '11 at 21:56
  • 1
    Side note - this should not result in a stale cache. While the cache state is maintained by nscd, NSS obtains the information by polling the daemon and not by reading a state off of the disk. If nscd is not running or able to service requests from NSS, then there is effectively no cache. – Andrew B May 01 '16 at 04:09

4 Answers4

0

Unfortunately these are bugs in the nscd init scripts and thhe status has no meaning. The init script is expecting the pid file to be /var/run/nscd.pid (which it would be if the init script was writing the pid file). Alas, nscd itself writes its pid file to /var/run/nscd/nscd.pid.

To simplify, try troubleshooting with nscd off.

If you want to know what ncsd is failing to start examine the output of strace -f /usr/sbin/nscd.

Mark Wagner
  • 17,764
  • 2
  • 30
  • 47
  • Can I ask what you mean by troubleshooting with `nscd` off? As far as I can tell, it's already not running. – Phunt Jun 15 '11 at 06:19
  • Have you ruled out other name resolution problems? That is what I meant. – Mark Wagner Jun 15 '11 at 15:58
  • I'm able to ping a new host from the server (just tried serverfault.com) and the DNS lookup works fine so I don't think that's the issue. What else could I look for with regards to name resolution issues? – Phunt Jun 15 '11 at 18:59
0

Explore the option of the package bind-chroot (and its dependencies). Simply yum install and modify your /etc/resolv.conf to point at 127.0.0.1. It is bit more robust than nscd out of the gates.

ForgeMan
  • 391
  • 1
  • 8
  • This only caches dns. It will not cache uid/gid. They would need to verify why they are using nscd. sssd is another option to replace nscd, but not trivial to configure. – Aaron Apr 28 '17 at 19:05
0

Nscd writes it's cache files to disk. I've seen problems with it before where it crashes starting if there's a problem reading this cache. Try deleting any files in the cache directory (should be /var/cache/nscd) and restarting nscd again.

theotherreceive
  • 8,235
  • 1
  • 30
  • 44
  • That directory doesn't exist on the server. I tried creating it and chown'd it to the nscd user but still no luck starting the service. – Phunt Jun 15 '11 at 18:52
  • Try /var/db/nscd – theotherreceive Jun 15 '11 at 23:22
  • Ah, that's where the files are. I moved all the files out of the dir and tried starting it - it generated new files (group, passwd, and hosts) but still failed to start. – Phunt Jun 16 '11 at 07:56
  • Rather than using the init script, try running nscd in debug mode ('nscd -d') and see if that produces any useful error messages – theotherreceive Jun 16 '11 at 10:30
0

I had a slightly different issue - I think it arose from running out of disk space on the system partition. I killed the service using $ sudo kill <pid>, then delete nscd.pid, then start the service. file location may differ based on OS and flavor. For CentOS (and presumably other Redhat variants), /var/run/nscd/nscd.pid

Startup:

$ sudo service nscd start

Nick
  • 131
  • 5