OPTIONS
翻译或纠错本页面

replSetSyncFrom

Description

replSetSyncFrom

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:

{ replSetSyncFrom: "hostname<:port>" }

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 run replSetSyncFrom. 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:

db.adminCommand( { replSetSyncFrom: "hostname<:port>" } )

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

rs.syncFrom("hostname<:port>")

注解

replSetSyncFrom and rs.syncFrom() provide a temporary override of default behavior. mongod will revert to the default sync behavior in the following situations:

  • The mongod instance restarts.
  • The connection between the mongod and the sync target closes.

在 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.

←   replSetStepDown resync  →