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.Tip
In
mongosh
, this command can also be run through thers.syncFrom()
helper method.Helper methods are convenient for
mongosh
users, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command.Run
replSetSyncFrom
in theadmin
database.
Syntax
The command has the following syntax:
db.adminCommand( { replSetSyncFrom: "hostname<:port>" } )
Command Fields
The command takes the following field:
Behavior
Sync Logic
If an initial sync operation is in progress when you run
replSetSyncFrom
, replSetSyncFrom
stops the in-progress initial sync and
restarts the sync process with the new target.
Only modify the default sync logic as needed, and always exercise caution.
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. See also
Replication Lag and Flow Control.
Persistence
replSetSyncFrom
provide a temporary override of default behavior.
mongod
will revert to the default sync behavior in the
following situations:
For more information the use of replSetSyncFrom
, see
Configure a Secondary's Sync Target.