- Reference >
- Database Commands >
- Replication Commands >
- replSetSyncFrom
replSetSyncFrom¶
On this page
Description¶
-
replSetSyncFrom
¶ Temporarily overrides the default sync target for the current
mongod
. This operation is useful for testing different patterns and in situations where a set member is not replicating from the desired host.To run
collStats
, use thedb.runCommand( { <command> } )
method.Changed in version 3.2: MongoDB 3.2 replica set members with
1 vote
cannot sync from members with0 votes
.The
replSetSyncFrom
command has the following form:{ replSetSyncFrom: "hostname<:port>" }
The
replSetSyncFrom
command has the following field:Field Type Description replSetSyncFrom
string The name and port number of the replica set member that this member should replicate from. Use the
[hostname]:[port]
form.
Behavior¶
Sync Logic¶
Only modify the default sync logic as needed, and always exercise
caution. replSetSyncFrom
will not affect an in-progress initial sync
operation. To affect the sync target for the initial sync, run
replSetSyncFrom
operation before initial sync.
If you run replSetSyncFrom
during initial sync, MongoDB
produces no error messages, but the sync target will not change until
after the initial sync operation.
Target¶
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
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, mongod
will log a warning but will
still replicate from the lagging member.
If you run replSetSyncFrom
during initial sync, MongoDB produces no error
messages, but the sync target will not change until after the initial
sync operation.
Persistence¶
replSetSyncFrom
provide a temporary override of default behavior.
mongod
will revert to the default sync behavior in the
following situations:
- The
mongod
instance restarts. - The connection between the
mongod
and the sync target closes. - If the sync target falls more than 30 seconds behind another member of the replica set.
For more information the use of replSetSyncFrom
, see
Configure a Secondary’s Sync Target.