rs.syncFrom() (original) (raw)

rs.syncFrom()

Temporarily overrides the default sync target for the current member.

Important

mongosh Method

This page documents a mongosh method. This is _not_the documentation for database commands or language-specific drivers, such as Node.js.

For the database command, see the replSetFreeze command.

For MongoDB API drivers, refer to the language-specificMongoDB driver documentation.

Specify the name of the member you want to replicate from in the form of [hostname]:[port].

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

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:

To use the rs.syncFrom() helper in mongosh:


rs.syncFrom("myHost:27017");

See also: