Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Linux administration isn't my thing so I'm a bit over my head here.

System information:

/proc/version -> Linux version 2.6.18-028stab091.2

/etc/debian_version -> 5.0.8

Whenever the server is shutdown & restarted, MongoDB isn't coming up. It looks like mongod isn't shutting down cleanly. The .lock file is still present & I can't bring it up manually until I remove this and run a --repair. If I look in mongod's log file I don't see the shutdown sequence, it just goes from a query to the startup.

Wed Jul 13 17:57:49 [conn1] update ps.profiles  query: { blah blah blah } 224ms
Thu Jul 14 07:07:51 MongoDB starting : pid=1167 port=27017 dbpath=/srv/db/ProfileServer 64-bit

I can see that the scripts are in place to handle shutdown & restart:

$ ls -l /etc/rc0.d/*mongodb
lrwxrwxrwx 1 root root 17 Feb 17 09:46 /etc/rc0.d/K20mongodb -> ../init.d/mongodb
$ ls -l /etc/rc2.d/*mongodb
lrwxrwxrwx 1 root root 17 Feb 17 09:46 /etc/rc2.d/S20mongodb -> ../init.d/mongodb
$ ls -l /etc/rc6.d/*mongodb
lrwxrwxrwx 1 root root 17 Feb 17 09:46 /etc/rc6.d/K20mongodb -> ../init.d/mongodb

I know that the scripts work. By running

sudo /etc/init.d/mongodb stop
sudo /etc/init.d/mongodb start

I see in the logs

... various other shutdown messages ...
Thu Jul 14 08:42:06 [interruptThread] shutdown: removing fs lock...
Thu Jul 14 08:42:06 dbexit: really exiting now
Thu Jul 14 08:42:12 MongoDB starting : pid=3184 port=27017 dbpath=/srv/db/ProfileServer 64-bit

Am I doing something obviously wrong? Is there any log file that will let me trace through the runlevel change?

share|improve this question
Is that a typo .../mongod start (or ../init.d/mongodb), or does the symlink in /etc/rcX.d really point to a different file in /etc/init.d ? – Mike Insch Jul 14 '11 at 13:59
Typo, I've corrected it. – Joe Strom Jul 14 '11 at 16:55
Is the a KXX script, where XX < 20 that would prevent mongodb from shutting down properly? – Mark Wagner Jul 14 '11 at 17:07
@embobo raises a very good point - on my system here, filesystems are unmounted around K09, so by the time a K20 script is reached the FS would be gone. Try moving your K20mongodb to around K05mongodb. – Mike Insch Jul 14 '11 at 17:20
K11atd is the only one <20. The unmount scripts are S40 and S60 – Joe Strom Jul 14 '11 at 17:24

I've successfully had this work using the packaged versions from the 10gen repos:

I suspect the issue here is how the shutdown is happening and how long it waits to kill the mongo process. If you don't want to go to the bother of installing a package just to look at some init scripts, head over to github and check out the source (one of the advantages of an open source DB :))

Compare and contrast with your own init scripts and set up to see where things might have gone wrong.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.