On this page本页内容
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 Replica Set Data Synchronization and 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 temporarily override the default sync target selection logic, you may manually configure a secondary member’s sync target to temporarily pull oplog entries. The following provide access to this functionality:
replSetSyncFrom
command, orrs.syncFrom()
helper in the mongo
shellChanged in version 3.4.在版本3.4中更改。
If an initial sync operation is in progress when you run replSetSyncFrom
/rs.syncFrom()
, replSetSyncFrom
/rs.syncFrom()
stops the in-progress initial sync and restarts the sync process with the new target. In previous versions, if you run replSetSyncFrom
/rs.syncFrom()
during initial sync, MongoDB produces no error messages, but the sync target will not change until after the initial sync operation.
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:
members[n].buildIndexes
setting.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.
replSetSyncFrom
/rs.syncFrom()
provide a temporary override of default behavior. mongod
will revert to the default sync behavior in the following situations:
To use the replSetSyncFrom
command in the mongo
shell:
To use the rs.syncFrom()
helper in the mongo
shell: