old lock file: \data\db\mongod.lock, probably means unclean shutdown
Published: May 9, 2011 , Updated: May 9, 2011 , Author: mkyong
A common error message if mongoDB machine is crashed or kill -9 command is issued.
Problem
When you issue command “mongod” to start the mongoDB server, it hits below errors, and the mongoDB server is unable to start.
************** old lock file: \data\db\mongod.lock. probably means unclean shutdown recommend removing file and running --repair see: http://dochub.mongodb.org/core/repair for more information ************* Mon May 09 12:37:43 [initandlisten] exception in initAndListen std::exception: old lock file, terminating Mon May 09 12:37:43 dbexit: Mon May 09 12:37:43 [initandlisten] shutdown: going to close listening sockets... Mon May 09 12:37:43 [initandlisten] shutdown: going to flush diaglog... Mon May 09 12:37:43 [initandlisten] shutdown: going to close sockets... Mon May 09 12:37:43 [initandlisten] shutdown: waiting for fs preallocator... Mon May 09 12:37:43 [initandlisten] shutdown: closing all files... Mon May 09 12:37:43 closeAllFiles() finished Mon May 09 12:37:43 dbexit: really exiting now
Solution
It means your mongoDB is crashed before, repair is need to start it!
To fix it :
1. Find the “\data\db\mongod.lock” file, and delete it.

2. Issue “mongod –repair” command.
>mongod --repair Mon May 09 12:42:57 [initandlisten] db version v1.8.1, pdfile version 4.5 //...... Mon May 09 12:42:57 [initandlisten] shutdown: going to close listening sockets... Mon May 09 12:42:57 [initandlisten] shutdown: going to flush diaglog... Mon May 09 12:42:57 [initandlisten] shutdown: going to close sockets... Mon May 09 12:42:57 [initandlisten] shutdown: waiting for fs preallocator... Mon May 09 12:42:57 [initandlisten] shutdown: closing all files... Mon May 09 12:42:57 closeAllFiles() finished Mon May 09 12:42:57 [initandlisten] shutdown: removing fs lock... Mon May 09 12:42:57 dbexit: really exiting now
Note
For more detail about how mongodb repair works, please refer to this MongoDB Durability and Repair guide.
For more detail about how mongodb repair works, please refer to this MongoDB Durability and Repair guide.
Note : You can find more similar articles at - Java MongoDB Tutorials






