Skip to content

DOCS-356 repair revision #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 24, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions source/includes/note-repair.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.. note::

When using :term:`journaling <journal>`, there is almost never
any need to run :dbcommand:`repairDatabase`. In the event of an
unclean shutdown, the server will be able restore the data files
to a pristine state automatically.
8 changes: 8 additions & 0 deletions source/includes/warning-repair.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. warning::

In general, if you have an intact copy of your data, such as
would exist on a very recent backup or an intact member of a
:term:`replica set`, **do not** use :dbcommand:`repairDatabase`
or related options like :func:`db.repairDatabase()` in the
:program:`mongo` shell or :option:`mongod --repair`. Restore
from an intact copy of your data.
37 changes: 17 additions & 20 deletions source/reference/commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1454,18 +1454,24 @@ Administration

.. dbcommand:: repairDatabase

.. include:: /includes/warning-repair.rst

.. include:: /includes/note-repair.rst

The :dbcommand:`repairDatabase` command checks and repairs errors and
inconsistencies with the data storage. The command is analogous to
a ``fsck`` command for file systems.

If your :program:`mongod` instance is not running with journaling
and you experience an unexpected system restart or crash, you
the system experiences an unexpected system restart or crash, and
you have *no* other intact replica set members with this data, you
should run the :dbcommand:`repairDatabase` command to ensure that
there are no errors in the data storage.

As a side effect, the :dbcommand:`repairDatabase` command will
compact the database, providing functionality equivalent to the
:dbcommand:`compact` command. Use the following syntax.
compact the database, as the :dbcommand:`compact` command and
reduce the total size of the data files on disk. Use the following
syntax:

.. code-block:: javascript

Expand All @@ -1485,6 +1491,9 @@ Administration

- Use the shell to run the above command, as above.

- Use the :func:`db.repairDatabase()` in the :program:`mongo`
shell.

- Run :program:`mongod` directly from your system's shell. Make sure
that :program:`mongod` isn't already running, and that you issue
this command as a user that has access to MongoDB's data
Expand All @@ -1499,23 +1508,11 @@ Administration
.. note::

This command will fail if your database is not a master or
primary. If you need to repair a secondary or slave node,
first restart the node as a standalone mongod by omitting the
:option:`--replSet <mongod --replSet>` or :option:`--slave
<mongod --slave>` options, as necessary.

- You may use the following shell helper:

.. code-block:: javascript

db.repairDatabase();

.. note::

When using :term:`journaling <journal>`, there is almost never any need to
run :dbcommand:`repairDatabase`. In the event of an unclean
shutdown, the server will be able restore the data files to a
pristine state automatically.
primary. In most cases, you should recover a corrupt secondary
using the data from an existing intact node. If you must
repair a secondary or slave node, first restart the node as a
standalone mongod by omitting the :option:`--replSet <mongod --replSet>`
or :option:`--slave <mongod --slave>` options, as necessary.

.. dbcommand:: shutdown

Expand Down
24 changes: 8 additions & 16 deletions source/reference/javascript.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1014,26 +1014,18 @@ Database

Removes the specified username from the database.

.. function:: db.repairDatabase()

Checks and repairs errors and inconsistencies with the data
storage. This function is analogous to a ``fsck`` operation for
file systems. Additionally, the function compacts the database to
minimize the current database's storage utilization, similar to the
:dbcommand:`compact` command.
.. function:: db.repairDatabase()

This function has the same effect as using the run-time option
":option:`mongod --repair`," but only operates on the current
database.
.. include:: /includes/warning-repair.rst

This command provides a wrapper around the database command
":dbcommand:`repairDatabase`".

.. warning::
.. include:: /includes/note-repair.rst

In general, if you have an intact :term:`replica set` member,
do not use :func:`db.repairDatabase()` and restore from the
other replica member.
:func:`db.repairDatabase()` provides a wrapper around the database
command :dbcommand:`repairDatabase`, and has the same effect as
the run-time option :option:`mongod --repair` option, limited to
*only* the current database. See :dbcommand:`repairDatabase` for
full documentation.

.. function:: db.runCommand(command)

Expand Down
13 changes: 6 additions & 7 deletions source/reference/mongod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,13 @@ Options

.. option:: --repair

Runs a repair routine on all databases.
Runs a repair routine on all databases. This is equivalent
to shutting down and running :dbcommand:`repairDatabase` database
command on all databases.

.. note::
.. include:: /includes/warning-repair.rst

Because :program:`mongod` rewrites all of the database files
during the repair routine, if you do not run :option:`--repair`
under the same user account as :program:`mongod` usually runs,
you will need to run ``chown`` on your database files to correct
the permissions before starting :program:`mongod` again.
.. include:: /includes/note-repair.rst

.. versionchanged:: 2.1.2

Expand All @@ -357,6 +355,7 @@ Options
:program:`mongod` cleanly and restart with the :option:`--repair`
option.


.. option:: --repairpath <path>

Specifies the root directory containing MongoDB data files, to use
Expand Down