Delayed Replica Set Members

On this page

Delayed members contain copies of areplica set’sdata set. However, a delayed member’s data set reflects an earlier, or delayed, state of the set. For example, if the current time is 09:52 and a member has a delay of an hour, the delayed member has no operation more recent than 08:52.

Because delayed members are a “rolling backup” or a running “historical” snapshot of the data set, they may help you recover from various kinds of human error. For example, a delayed member can make it possible to recover from unsuccessful application upgrades and operator errors including dropped databases and collections.

Considerations

Requirements

Delayed members:

  • Must be
    priority 0
    members. Set the priority to 0 to prevent a delayed member from becoming primary.
  • Should be
    hidden
    members. Always prevent applications from seeing and querying delayed members.
  • do
    vote in
    elections
    for primary, if
    members[n].votes
    is set to 1.

Behavior

Delayed members copy and apply operations from the sourceoplogon a delay. When choosing the amount of delay, consider that the amount of delay:

  • must be equal to or greater than your expected maintenance window durations.
  • must be
    smaller
    than the capacity of the oplog. For more information on oplog size, see
    Oplog Size
    .

Sharding

In sharded clusters, delayed members have limited utility when thebalanceris enabled. Because delayed members replicate chunk migrations with a delay, the state of delayed members in a sharded cluster are not useful for recovering to a previous state of the sharded cluster if any migrations occur during the delay window.

Example

In the following 5-member replica set, the primary and all secondaries have copies of the data set. One member applies operations with a delay of 3600 seconds (one hour). This delayed member is alsohidden_and is a_priority 0 member.

延迟节点 - 图1

Configuration

A delayed member has itsmembers[n].priorityequal to0,members[n].hiddenequal totrue, and itsmembers[n].slaveDelayequal to the number of seconds of delay:

  1. {
  2. "_id" : <num>,
  3. "host" : <hostname:port>,
  4. "priority" : 0,
  5. "slaveDelay" : <seconds>,
  6. "hidden" : true
  7. }

To configure a delayed member, seeConfigure a Delayed Replica Set Member.