Recover a Standalone after an Unexpected Shutdown¶
When a standalone
mongod instance has journaling disabled
, an unclean shutdown may leave the data in an
inconsistent state. Following an unclean shutdown, if a non-empty
mongod.lock file exists,
mongod instance logs the
following message upon restart:
Detected unclean shutdown - mongod.lock is not empty.
Do not use this tutorial to recover a member of a replica set. Instead, you should either restore from a backup or resync from another member of the set, as described in Resync a Member of a Replica Set.
|||By default, MongoDB runs with journaling enabled to prevent data inconsistency in the event of an unclean shutdown. To shut down cleanly, see Stop mongod Processes.|
Run the repair operation as the same user that normally runs the
mongod process to avoid changing the permissions of the
MongoDB data files.
Create a backup of the data files.¶
Create a backup copy of the data files in the
Issue a command similar to the following:
mongod --dbpath /data/db --repair
Upon completion, the
dbpath should contain the repaired data files and an empty
mongod.lock file. 
|||(1, 2) Generally, you should not manually remove the |