- 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.
replSetSyncFromallows you to explicitly configure which host the currentmongodwill 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
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 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
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. If:- the
mongodinstance restarts or - the connection to the sync target closes;
then, the
mongodinstance 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