- Reference >
- Database Commands >
- Replication Commands >
- replSetSyncFrom
replSetSyncFrom¶
On this page
Description¶
-
replSetSyncFrom
¶ New in version 2.2.
Explicitly configures which host the current
mongod
pulls 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
replSetSyncFrom
command has the following form:The
replSetSyncFrom
command has 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.
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
mongod
on 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
mongod
instance 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,
mongod
will log a warning but will still replicate from the lagging member.If you run
replSetSyncFrom
during 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
mongo
shell, use the following invocation:You may also use the
rs.syncFrom()
helper in themongo
shell in an operation with the following form:Note
replSetSyncFrom
andrs.syncFrom()
provide a temporary override of default behavior.mongod
will 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
mongod
will revert to the default sync target.