19

I am using mongodb-v1.8.1. Unfortunately my server gets hanged and i restarted my server.Once it comes back i could-not start the MongoDB. I removed the mongo.lock file and ran repair database query.Now mongo working fine. I am baffled with the mongo.lock file.What is the use of the mongo.lock file?.Removing the mongo.lock file will affect my existing data? Please let me know your suggestion..

Thanks,

2

1 Answer 1

27

Mongodb always creates the mongodb.lock file when the server starts and drops it before mongodb is stopped.

Removing mongodb.lock does not affect any data it just means that mongodb was not stopped correctly. So, you are correct in removing this file and running with the -repair option should fix database.

4
  • 1
    Hi @Andrew, Thanks for your reply..For automated removal of mongo.lock file mongodb should run as deamon process?
    – kumar_88
    Jul 28, 2011 at 11:12
  • Hi @Andrew, I am not running mongo as daemon process.Do i have to run as daemon?.If mongo run as daemon it would remove the file whenever the server restarts?..Please provide information on this....
    – kumar_88
    Jul 28, 2011 at 11:34
  • 1
    @kumar_88 you should never remove this file manually. If you happen to have to you possibly has already lost some data. If you suffer from this consider enabling journaling: mongodb.org/display/DOCS/Journaling
    – pingw33n
    Jul 28, 2011 at 12:30
  • 1
    "you should never remove this file AUTOMATICALLY" you mean ;)
    – faebster
    Jan 12, 2014 at 20:41

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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