- Reference >
- Database Commands >
- replSetSyncFrom
replSetSyncFrom¶
-
replSetSyncFrom
¶ New in version 2.2.
Options: - host – Specifies the name and port number of the replica set member
that this member replicates from. Use
the
[hostname]:[port]
form.
replSetSyncFrom
allows you to explicitly configure which host the currentmongod
will poll oplog entries from. This operation may be useful for testing different patterns and in situations where a set member is not replicating from the host you want. The member to replicate from must be a valid source for data in the set.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 return and log a warning, but it still will replicate from the member that is behind.If you run
rs.syncFrom()
during initial sync, MongoDB produces no error messages, but the sync target will not change until after the initial sync operation.The command has the following prototype form:
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. If:- the
mongod
instance restarts or - the connection to the sync target closes;
then, the
mongod
instance will revert to the default sync logic and target.- host – Specifies the name and port number of the replica set member
that this member replicates from. Use
the