- Reference >
- Database Commands >
- Replication Commands >
- replSetSyncFrom
replSetSyncFrom¶
On this page
Description¶
-
replSetSyncFrom¶ New in version 2.2.
Explicitly configures which host the current
mongodpulls oplog entries from. This operation is useful for testing different patterns and in situations where a set member is not replicating from the desired host.The
replSetSyncFromcommand has the following form:The
replSetSyncFromcommand has the following field:Field Type Description replSetSyncFromstring The name and port number of the replica set member that this member should replicate from. Use the [hostname]:[port]form.
The Target Member¶
The member to replicate from must be a valid source for data in the set. The member cannot be:
- The same as the
mongodon which you runreplSetSyncFrom. In other words, a member cannot replicate from itself.- An arbiter, because arbiters do not hold data.
- A member that does not build indexes.
- An unreachable member.
- A
mongodinstance that is not a member of the same replica set.If you attempt to replicate from a member that is more than 10 seconds behind the current member,
mongodwill log a warning but will still replicate from the lagging member.If you run
replSetSyncFromduring initial sync, MongoDB produces no error messages, but the sync target will not change until after the initial sync operation.
Run from the mongo Shell¶
To run the command in the
mongoshell, use the following invocation:You may also use the
rs.syncFrom()helper in themongoshell in an operation with the following form:Note
replSetSyncFromandrs.syncFrom()provide a temporary override of default behavior.mongodwill revert to the default sync behavior in the following situations:Changed in version 2.4: The sync target falls more than 30 seconds behind another member of the replica set; the
mongodwill revert to the default sync target.