replSetSyncFrom (original) (raw)

replSetSyncFrom

Temporarily overrides the default sync target for the currentmongod. 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 the rs.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 the admin database.

This command is available in deployments hosted in the following environments:

Important

This command is not supported in M0, M2, M5, M10+, and Flex clusters. For more information, see Unsupported Commands.

The command has the following syntax:


db.adminCommand(

   {

     replSetSyncFrom: "hostname<:port>"

   }

 )

The command takes 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.Replica set members with 1 votecannot sync from members with 0 votes.

For replSetSyncFrom to override the default sync target,settings.chainingAllowed must be set to true.

If settings.chainingAllowed is set to false, replSetSyncFrom returnsok:1 but does not set the sync target.

If an initial sync operation is in progress when you runreplSetSyncFrom, 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.

The member to sync from must be a valid source for data in the set. To sync from a member, the member must:

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 alsoReplication Lag and Flow Control.

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, seeConfigure a Self-Managed Secondary's Sync Target.