@@ -33,6 +33,7 @@ suggestions for administers of replica sets.
33
33
- :doc:`/tutorial/change-hostnames-in-a-replica-set`
34
34
- :doc:`/tutorial/convert-secondary-into-arbiter`
35
35
- :doc:`/tutorial/reconfigure-replica-set-with-unavailable-members`
36
+ - :doc:`/tutorial/recover-data-following-unexpected-shutdown`
36
37
37
38
.. _replica-set-node-configurations:
38
39
.. _replica-set-member-configurations:
@@ -365,7 +366,8 @@ the following to prepare the new member's :term:`data directory <dbpath>`:
365
366
difference in the amount of time between the most recent operation and
366
367
the most recent operation to the database exceeds the length of the
367
368
:term:`oplog` on the existing members, then the new instance will have
368
- to completely re-synchronize.
369
+ to completely resynchronize, as described in
370
+ :ref:`replica-set-resync-stale-member`.
369
371
370
372
Use :method:`db.printReplicationInfo()` to check the current state of
371
373
replica set members with regards to the oplog.
@@ -558,6 +560,90 @@ the oplog. For a detailed procedure, see
558
560
559
561
.. include:: /includes/procedure-change-oplog-size.rst
560
562
563
+ .. _replica-set-resync-stale-member:
564
+
565
+ Resyncing a Member of a Replica Set
566
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
567
+
568
+ When a member's data falls too far behind the :term:`oplog` to catch up,
569
+ the member and it's data are considered "stale". A member's data is too
570
+ far behind when the oplog on the :term:`primary` has overwritten its
571
+ entries before the member has copied them. When that occurs, you must
572
+ resync the member by removing its data and replacing it with up-to-date
573
+ data.
574
+
575
+ To do so, use one of the following approaches:
576
+
577
+ - Restart the machine with an empty data directory and let MongoDB's
578
+ automatic syncing feature restore the data. This approach requires
579
+ fewer steps but can take longer to replace the data.
580
+
581
+ See :ref:`replica-set-auto-resync-stale-member`.
582
+
583
+ - Restart the machine with a copy of a recent data directory from
584
+ another member in the :term:`replica set`. This procedure can replace
585
+ the data more quickly but requires more manual steps.
586
+
587
+ See :ref:`replica-set-resync-by-copying`.
588
+
589
+ .. index:: replica set; resync
590
+ .. _replica-set-auto-resync-stale-member:
591
+
592
+ Automatically Resync a Stale Member
593
+ ```````````````````````````````````
594
+
595
+ This procedure relies on MongoDB's automatic syncing feature to restore
596
+ the data on the stale member. For an overview of how MongoDB syncs
597
+ replica sets, see :ref:`replica-set-syncing`.
598
+
599
+ To resync the stale member:
600
+
601
+ 1. Stop the member's :program:`mongod` instance using the
602
+ :option:`mongod --shutdown` option. Make sure to set
603
+ :option:`--dbpath <mongod --dbpath>` to the member's data directory.
604
+
605
+ .. code-block:: sh
606
+
607
+ mongod --dbpath /data/db/ --shutdown
608
+
609
+ #. Delete all data and subdirectories from the member's data directory
610
+ such that the directory is empty.
611
+
612
+ #. Restart the :program:`mongod` instance on the member. Consider the
613
+ following example:
614
+
615
+ .. code-block:: sh
616
+
617
+ mongod --dbpath /data/db/ --replSet rsProduction
618
+
619
+ MongoDB resyncs the member. Resyncing may take a long time, depending on
620
+ the size of the database and speed of the network.
621
+
622
+ .. index:: replica set; resync
623
+ .. _replica-set-resync-by-copying:
624
+
625
+ Resync by Copying Data from Another Member
626
+ ``````````````````````````````````````````
627
+
628
+ This approach uses the data directory of an existing member to "seed"
629
+ the stale member. The data must be recent enough to allow the new member
630
+ to catch up with the :term:`primary` member's :term:`oplog`.
631
+
632
+ To resync by copying data from another member, use one of the following
633
+ approaches:
634
+
635
+ - Create a snapshot of another member's data and then restore that
636
+ snapshot to the stale member. Use the snapshot procedures in
637
+ :doc:`/administration/backups`.
638
+
639
+ - Lock another member's database with the :method:`db.fsyncLock()`
640
+ command, copy that data, and then restore the data to the stale
641
+ member. Use the procedures for backup storage in
642
+ :doc:`/administration/backups`.
643
+
644
+ - Use the :dbcommand:`copydb` and :dbcommand:`clone` commands, as
645
+ described in :doc:`/tutorial/copy-databases-between-instances`.
646
+
561
647
.. _replica-set-security:
562
648
563
649
Replica Set Security
0 commit comments