Linux – mongoDB – Linux Service Startup/Shutdown is Failing (possible unclean shutdown)

init.dlinuxmongodb

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?

Best Answer

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

http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages http://www.mongodb.org/display/DOCS/CentOS+and+Fedora+Packages

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 :))

https://github.com/mongodb/mongo/blob/master/rpm/init.d-mongod

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

Related Topic