This version of the documentation is archived and no longer supported.



New in version 2.2.

  • 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 current mongod 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:

{ replSetSyncFrom: "[hostname]:[port]" }

To run the command in the mongo shell, use the following invocation:

db.adminCommand( { replSetSyncFrom: "[hostname]:[port]" } )

You may also use the rs.syncFrom() helper in the mongo shell, in an operation with the following form:



replSetSyncFrom and rs.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.