Skip to content

Consolidate docs for replSetSyncFrom command #1980

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

Closed
wants to merge 1 commit into from
Closed
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
22 changes: 22 additions & 0 deletions source/includes/fact-replSetSyncFrom-target-member.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The member to sync from must be a valid source for data in the set.
To sync from a member, the member must:

- Have data. It cannot be an arbiter, in startup or recovering mode, and
must be able to answer data queries.

- Be accessible.

- Be a member of the same set in the replica set configuration.

- Build indexes with the
:data:`~local.system.replset.members[n].buildIndexes` setting.

- A different member of the set, to prevent syncing from itself.

If you attempt to replicate from a member that is more than 10 seconds
behind the current member, :program:`mongod` will log a warning but will
still replicate from the lagging member.

If you run :dbcommand:`replSetSyncFrom` during initial sync, MongoDB
produces no error messages, but the sync target will not change until
after the initial sync operation.
56 changes: 6 additions & 50 deletions source/reference/command/replSetSyncFrom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ Description

.. versionadded:: 2.2

Explicitly configures
which host the current :program:`mongod` pulls :term:`oplog`
entries from. This operation is useful for testing different
patterns and in situations where a set member is not replicating from
the desired host.
Explicitly configures which host the current :program:`mongod` pulls
:term:`oplog` entries from. This operation is useful for testing
different patterns and in situations where a set member is not
replicating from the desired host.

The :dbcommand:`replSetSyncFrom` command has the following form:

Expand All @@ -27,48 +26,5 @@ Description

.. include:: /reference/command/replSetSyncFrom-field.rst

The Target Member
-----------------

The member to replicate from must be a valid source for data in the
set. The member cannot be:

- The same as the :program:`mongod` on which you run
:dbcommand:`replSetSyncFrom`. In other words, a member cannot
replicate from itself.
- An arbiter, because arbiters do not hold data.
- A member that does not build indexes.
- An unreachable member.
- A :program:`mongod` instance that is not a member of the same
replica set.

If you attempt to replicate from a member that is more than 10 seconds
behind the current member, :program:`mongod` will log a
warning but will still replicate from the lagging member.

If you run :dbcommand:`replSetSyncFrom` during initial sync, MongoDB
produces no error messages, but the sync target will not change
until after the initial sync operation.

Run from the ``mongo`` Shell
----------------------------

To run the command in the :program:`mongo` shell, use the following
invocation:

.. code-block:: javascript

db.adminCommand( { replSetSyncFrom: "hostname<:port>" } )

You may also use the :method:`rs.syncFrom()` helper in the
:program:`mongo` shell in an operation with the following form:

.. code-block:: javascript

rs.syncFrom("hostname<:port>")

.. note::

.. include:: /includes/fact-replica-set-sync-from-is-temporary.rst

.. slave-ok, admin-only
See :doc:`/tutorial/configure-replica-set-secondary-sync-target` for
more information on the use of :dbcommand:`replSetSyncFrom`.
3 changes: 3 additions & 0 deletions source/reference/method/rs.syncFrom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ rs.syncFrom()
member you want to replicate from in the form of ``[hostname]:[port]``.

See :dbcommand:`replSetSyncFrom` for more details.

See :doc:`/tutorial/configure-replica-set-secondary-sync-target` for
details how to use this command.
47 changes: 44 additions & 3 deletions source/tutorial/configure-replica-set-secondary-sync-target.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,34 @@ Configure a Secondary's Sync Target

.. default-domain:: mongodb

Overview
--------

Secondaries capture data from the primary member to maintain an up to date
copy of the sets' data. However, by default secondaries may automatically
change their sync targets to secondary members based on changes in the
ping time between members and the state of other members’ replication. See
:doc:`/core/replica-set-sync` and
:doc:`/tutorial/manage-chained-replication` for more information.

For some deployments, implementing a custom replication sync topology may
be more effective than the default sync target selection logic. MongoDB
provides the ability to specify a host to use as a sync target.

To override the default sync target selection logic, you may manually
configure a :term:`secondary` member's sync target for pulling
:term:`oplog` entries temporarily. The following operations provide
access to this functionality:
configure a :term:`secondary` member's sync target to temporarily pull
:term:`oplog` entries. The following provide access to this functionality:

- :dbcommand:`replSetSyncFrom` command, or

- :method:`rs.syncFrom()` helper in the :program:`mongo` shell

Considerations
--------------

Sync Logic
~~~~~~~~~~

Only modify the default sync logic as needed, and always exercise
caution. :method:`rs.syncFrom()` will not affect an in-progress
initial sync operation. To affect the sync target for the initial sync, run
Expand All @@ -25,3 +44,25 @@ after the initial sync operation.
.. note::

.. include:: /includes/fact-replica-set-sync-from-is-temporary.rst

The Sync Target
~~~~~~~~~~~~~~~

.. include:: /includes/fact-replSetSyncFrom-target-member.rst

Procedure
---------

To use the :dbcommand:`replSetSyncFrom` command in the :program:`mongo` shell:

.. code-block:: javascript

db.adminCommand( { replSetSyncFrom: "hostname<:port>" } )

To use the :method:`rs.syncFrom()` helper in the :program:`mongo` shell:

.. code-block:: javascript

rs.syncFrom("hostname<:port>")

.. slave-ok, admin-only