Skip to content

Commit 3808767

Browse files
committed
clarifications of how to resync if stale in a replica set. also removed mention of fsyncLock() as it often blocks the other server so it can only be used with care and thus you would really have to go read the full backups page before using it
1 parent 6cfa8d8 commit 3808767

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

source/administration/replica-sets.txt

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -715,28 +715,29 @@ To do so, use one of the following approaches:
715715

716716
Automatically Resync a Stale Member
717717
```````````````````````````````````
718-
719718
This procedure relies on MongoDB's regular process for initial
720719
sync. This will restore the data on the stale member to reflect the
721720
current state of the set. For an overview of MongoDB initial sync
722721
process, see the :ref:`replica-set-syncing` section.
723722

724723
To resync the stale member:
725724

726-
1. Stop the member's :program:`mongod` instance using the
727-
:option:`mongod --shutdown` option. Make sure to set
725+
1. Stop the stale member's :program:`mongod` instance/process.
726+
One way to do this is to run
727+
:option:`mongod --shutdown` on the stale member machine. Set
728728
:option:`--dbpath <mongod --dbpath>` to the member's data
729729
directory, as in the following:
730730

731731
.. code-block:: sh
732732

733733
mongod --dbpath /data/db/ --shutdown
734734

735-
#. Delete all data and sub-directories from the member's data directory
736-
such that the directory is empty.
735+
#. Delete all data and sub-directories from the member's data directory.
736+
We do this so that we can then resync from a completely clean and empty
737+
data image for the stale member.
738+
Consider making a backup first.
737739

738-
#. Restart the :program:`mongod` instance on the member. Consider the
739-
following example:
740+
#. Restart the :program:`mongod` instance on the member. For example:
740741

741742
.. code-block:: sh
742743

@@ -746,29 +747,30 @@ To resync the stale member:
746747
take a long time, depending on the size of the database and speed
747748
of the network. Remember that this operation may have an impact on
748749
the working set and/or traffic to existing primary other members of
749-
the set.
750+
the set. Note the initial sync can only occur if another member of the set is
751+
up and healthy (that member will be the source for syncing).
750752

751753
.. index:: replica set; resync
752754
.. _replica-set-resync-by-copying:
753755

754-
Resync by Copying Data from Another Member
756+
Resync by Copying All Datafiles from Another Member
755757
``````````````````````````````````````````
756758

757-
This approach uses the data directory of an existing member to "seed"
758-
the stale member. The data must be recent enough to allow the new member
759-
to catch up with the :term:`oplog`.
760-
761-
To resync by copying data from another member, use one of the following
762-
approaches:
763-
764-
- Create a snapshot of another member's data and then restore that
765-
snapshot to the stale member. Use the snapshot procedures in
766-
:doc:`/administration/backups`.
767-
768-
- Lock another member's data with the :method:`db.fsyncLock()`
769-
command, copy all of the data in the data directory, and then restore the data to the stale
770-
member. Use the procedures for backup storage in
771-
:doc:`/administration/backups`.
759+
This approach uses the datafiles of a healthy member of the replica set
760+
(or a restored backup thereof)
761+
to "seed" the stale member. Note the data image must be recent enough to allow the new member
762+
to catch up with the :term:`oplog`; an older backup would likely be too stale.
763+
764+
Note that in general you cannot simply copy the datafiles from another replica
765+
set member if it is running, as that mongod will likely be changing those datafiles
766+
while our copy is underway; thus in our image will not automatically be consistent.
767+
There are several approaches to get a consistent image from another server; these
768+
approaches are analogous to making a backup of the datafiles on that server. See the
769+
:doc:`/administration/backups` page for details.
770+
771+
Once you have copied all datafiles (including subdirectories) from the other set member,
772+
restart the local mongod and it should come online after catching up on any write operations
773+
which have occurred in the cluster since the time of the restore image.
772774

773775
.. _replica-set-security:
774776

0 commit comments

Comments
 (0)