@@ -1454,18 +1454,23 @@ Administration
1454
1454
1455
1455
.. dbcommand:: repairDatabase
1456
1456
1457
+ .. include:: /includes/warning-repair.rst
1458
+
1459
+ .. include:: /includes/note-repair.rst
1460
+
1457
1461
The :dbcommand:`repairDatabase` command checks and repairs errors and
1458
1462
inconsistencies with the data storage. The command is analogous to
1459
1463
a ``fsck`` command for file systems.
1460
1464
1461
1465
If your :program:`mongod` instance is not running with journaling
1462
- and you experience an unexpected system restart or crash, you
1466
+ the system experiences an unexpected system restart or crash, and
1467
+ you have *no* other intact replica set members with this data, you
1463
1468
should run the :dbcommand:`repairDatabase` command to ensure that
1464
1469
there are no errors in the data storage.
1465
1470
1466
1471
As a side effect, the :dbcommand:`repairDatabase` command will
1467
- compact the database, providing functionality equivalent to the
1468
- :dbcommand:`compact` command. Use the following syntax.
1472
+ compact the database, as the :dbcommand:`compact` command. Use the
1473
+ following syntax.
1469
1474
1470
1475
.. code-block:: javascript
1471
1476
@@ -1485,6 +1490,9 @@ Administration
1485
1490
1486
1491
- Use the shell to run the above command, as above.
1487
1492
1493
+ - Use the :func:`db.repairDatabase()` in the :program:`mongo`
1494
+ shell.
1495
+
1488
1496
- Run :program:`mongod` directly from your system's shell. Make sure
1489
1497
that :program:`mongod` isn't already running, and that you issue
1490
1498
this command as a user that has access to MongoDB's data
@@ -1499,23 +1507,12 @@ Administration
1499
1507
.. note::
1500
1508
1501
1509
This command will fail if your database is not a master or
1502
- primary. If you need to repair a secondary or slave node,
1503
- first restart the node as a standalone mongod by omitting the
1504
- :option:`--replSet <mongod --replSet>` or :option:`--slave
1505
- <mongod --slave>` options, as necessary.
1506
-
1507
- - You may use the following shell helper:
1508
-
1509
- .. code-block:: javascript
1510
-
1511
- db.repairDatabase();
1512
-
1513
- .. note::
1514
-
1515
- When using :term:`journaling <journal>`, there is almost never any need to
1516
- run :dbcommand:`repairDatabase`. In the event of an unclean
1517
- shutdown, the server will be able restore the data files to a
1518
- pristine state automatically.
1510
+ primary. In most cases, you should recover a currupt secondary
1511
+ using the data from an existing intact node. If you need to
1512
+ repair a secondary or slave node, first restart the node as a
1513
+ standalone mongod by omitting the :option:`--replSet <mongod
1514
+ --replSet>` or :option:`--slave <mongod --slave>` options, as
1515
+ necessary.
1519
1516
1520
1517
.. dbcommand:: shutdown
1521
1518
0 commit comments