Configure a Delayed Replica Set Member¶
The following example sets a 1-hour delay on a secondary member
currently at the index
0 in the
members array. To set the delay, issue
the following sequence of operations in a
connected to the primary:
cfg = rs.conf() cfg.members.priority = 0 cfg.members.hidden = true cfg.members.slaveDelay = 3600 rs.reconfig(cfg)
After the replica set reconfigures, the delayed secondary member cannot
become primary and is hidden from applications. The
slaveDelay value delays both
replication and the member’s oplog by 3600 seconds (1 hour).
When updating the replica configuration object, access the replica set
members in the
members array with the
array index. The array index begins with
0. Do not confuse
this index value with the value of the
_id field in each document in
rs.reconfig()shell method can force the current primary to step down, which causes an election. When the primary steps down, the
mongodcloses all client connections. While this typically takes 10-20 seconds, try to make these changes during scheduled maintenance periods.
- To successfully reconfigure a replica set, a majority of the members must be accessible. If your replica set has an even number of members, add an arbiter to ensure that members can quickly obtain a majority of votes in an election for primary.