We have moved to www.dataGenX.net, Keep Learning with us.

Monday, March 23, 2015

MongoDB is unable to start due to lock file

While starting MongoDB server, You are facing that MongoDB is not getting up with a exception says -

Sun Jan 18 12:27:03.884 [initandlisten] exception in initAndListen: 10310 Unable to lock file: /data/db/mongod.lock. Is a mongod instance already running?, terminating
Sun Jan 18 12:27:03.884 dbexit:


Normally, we are facing this issue due to 1. improper MongoDB server shutdown or 2. someone else is started the mongo server. In the second case, we dont have any issue, we can connect to out db without issue.

For the first case -
1. try to delete the file 'mongod.lock', by default it is existing under /data/db directory
2. execute command 'mongod --repair'
3. Now, try to start 'mongod'
4. If still facing the same issue - follow below commands
 #    lsof -i:27017
 
COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
mongod  8335 hduser   10u  IPv4  43617      0t0  TCP *:27017 (LISTEN)
mongod  8335 hduser   12u  IPv4  45790      0t0  TCP dsadmin:27017->dsadmin:42137 (ESTABLISHED)
mongo   8816 hduser    3u  IPv4  45789      0t0  TCP dsadmin:42137->dsadmin:27017 (ESTABLISHED)

# kill -9 8335 8816

5. This will kill the connection which is not closed properly before mongodb shutdown.
6. Now start the MongoDB by executing 'mongod'
 


Like the Facebook Page & join Group
https://www.facebook.com/DataStage4you
https://www.facebook.com/groups/DataStage4you

https://twitter.com/datastage4you
https://groups.google.com/d/forum/datastage4you
For WHATSAPP group , drop a msg to 91-88-00-906098


No comments :

Post a Comment