Hello, everyone, why did mongodb delete mongoD. Lock when starting Mongo the next day and then all the data was lost? What is the reason?
First of all,
mongoA lock file created in the hard disk after the server starts, if you exit normally
mongodService, even if the file still exists, it will not affect the next startup.
mongodServing. At the same time, this file will also record some states of mongod during the running process, so as to obtain abnormal information tips when restarting the service normally.
Note: generally only in abnormal exit
mongodService, only need to delete
mongod.lockDocuments. Exit normally without deletion.
Now the data is lost, it should be abnormal exit, i.e. the database crashes, if not
Open journal, then there is no way to ensure the integrity of the data.
Therefore, in a production environment, it is common to
If the data has not been backed up, you can only try mongod’s built-in repair and run it.
mongod --dbpath /path/to/corrupt/data --repair
Do you want to delete it
When mongod is normally closed, mongod.lock file will be cleared, and it will be known that it was completely closed last time when it is started next time. On the contrary, if the lock file is not cleared, mongod does not normally close.
If mongod detects that there is no normal shutdown, it will not let you start again. When starting, it will print the information of the last abnormal shutdown and require you to copy a copy of the data. However, some people have realized that this check can be bypassed by deleting this lock file. So there is a reason to delete this file. Deleting the lock file at startup means that you do not know or care if your data is corrupted. If Mongoose cannot be started, please repair your data instead of deleting the lock file.