At work we have had a major problem with one of our web applications. It was erroring frequently for one client, but not for others. Viewing the application log in event viewer, numerous database timeouts were listed, but what was causing this? After much deliberation, we suddenly recalled that perfmon may shine more of a light on this. This post gives instructions on how to use perfmon. Once set up and counters were running, I logged into the site and mointored perfmon whilst doing a few things. Suddenly connections rose dramatically as I began using a certain bit of fucntionality. Now all thats left to do is to fix it, but I think this will be the easier part of the job…
I have got this error a few times and it usually occurs after my laptop has not shutdown Ubuntu correctly. To confirm this you can look at the mongoDB log which for me is located at /var/log/mongodb/mongodb.log and you find this error:
Unclean shutdown detected.
Please visit http://dochub.mongodb.org/core/repair for recovery instructions.
When you get this error follow the instructions given in this post this post, which are as follows: work for me every time…
Manually remove the lockfile: sudo rm /var/lib/mongodb/mongod.lock
Run the repair script: sudo -u mongodb mongod -f /etc/mongodb.conf –repair.
You must run this command as the mongodb user. If you run it as root, then root will own files in /var/lib/mongodb/ that are necessary to run the mongodb daemon and therefore when the daemon trys to run later as the mongodb user, it won’t have permissions to start. In that case you’ll get this error: Unable to create / open lock file for lockfilepath: /var/lib/mongodb/mongod.lock errno:13 Permission denied, terminating.
On Ubuntu, you must specify the configuration file /etc/mongodb.conf using the -f flag. Otherwise it will look for the data files in the wrong place and you will see the following error: dbpath (/data/db/) does not exist, terminating.
Now you can start your MongoDB server with sudo start mongodb and verify it is running with sudo status mongodb and by trying to connect to it with mongo test.