@@ -6,7 +6,7 @@ Recover MongoDB Data following Unexpected Shutdown
6
6
7
7
If MongoDB does not shutdown cleanly [#clean-shutdown]_ the on-disk
8
8
representation of the data files will likely reflect an inconsistent
9
- state which could lead to data corruption.
9
+ state which could lead to data corruption. [#validation]_
10
10
11
11
To prevent data inconsistency and corruption, always shut down the
12
12
database cleanly and use the :ref:`durability journaling
@@ -23,7 +23,7 @@ the :program:`mongod` instance with an empty :setting:`dbpath` and
23
23
allow MongoDB to resync the data.
24
24
25
25
.. seealso:: The :doc:`/administration` documents, including
26
- :ref:`replica-set-syncing`, and the
26
+ :ref:`Replica Set Syncing < replica-set-syncing> `, and the
27
27
documentation on the :setting:`repair`, :setting:`repairpath`, and
28
28
:setting:`journal` settings.
29
29
@@ -32,6 +32,13 @@ allow MongoDB to resync the data.
32
32
"Control-C" (when running :program:`mongod` in interactive mode,)
33
33
or ``kill $(pidof mongod)`` or ``kill -2 $(pidof mongod)``.
34
34
35
+ .. [#validation] You can also use the :method:`db.collection.validate()`
36
+ method to test the integrity of a single collection. However, this
37
+ process is time consuming, and without journaling you can safely
38
+ assume that the data is in an invalid state and you should either
39
+ run the repair operation or resync from an intact member of the
40
+ replica set.
41
+
35
42
Process
36
43
-------
37
44
@@ -72,7 +79,7 @@ Overview
72
79
.. warning:: Recovering a member of a replica set.
73
80
74
81
Do not use this procedure to recover a member of a :term:`replica set`.
75
- Instead you should either restore from a :doc:`backup </administration/backups>`
82
+ Instead you should either restore from a :doc:`backup </administration/backups>`
76
83
or resync from an intact member of the set, as described in :ref:`replica-set-resync-stale-member`.
77
84
78
85
There are two processes to repair data files that result from an
@@ -95,6 +102,12 @@ unexpected shutdown:
95
102
You must remove the ``mongod.lock`` file before using this
96
103
procedure.
97
104
105
+ .. note::
106
+
107
+ :option:`--repair <mongod --repair>` functionality is also
108
+ available in the shell with the :method:`db.repairDatabase()`
109
+ helper for the :dbcommand:`repairDatabase` command.
110
+
98
111
Procedures
99
112
~~~~~~~~~~
100
113
0 commit comments