mongodb mongo.lock 文件有什么用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6857781/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 12:11:35  来源:igfitidea点击:

What is the use of the mongo.lock file?

mongodb

提问by kumar_88

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..

我正在使用 mongodb-v1.8.1。不幸的是,我的服务器挂了,我重新启动了我的服务器。一旦它回来,我就无法启动 MongoDB。我删除了 mongo.lock 文件并运行修复数据库查询。现在 mongo 工作正常。我对mongo.lock文件很困惑。mongo.lock文件有什么用?删除mongo.lock文件会影响我现有的数据吗?请让我知道你的建议..

Thanks,

谢谢,

回答by Andrew Orsich

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

mongodb 总是在服务器启动时创建 mongodb.lock 文件,并在 mongodb 停止之前删除它。

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.

删除 mongodb.lock 不会影响任何数据,只是意味着 mongodb 没有正确停止。因此,您删除此文件并使用 -repair 选项运行应该修复数据库是正确的。