On this page本页内容
To configure a delayed secondary member, set its 若要配置延迟的次要成员,请将其members[n].priority
value to 0
, its members[n].hidden
value to true
, and its members[n].secondaryDelaySecs
value to the number of seconds to delay.members[n].priority
值设置为0
,将其members[n].hidden
值设置为true
,将members[n].secondaryDelaySecs
值设置为延迟的秒数。
The length of the secondary 次要members[n].secondaryDelaySecs
must fit within the window of the oplog. members[n].secondaryDelaySecs
的长度必须适合oplog的窗口。If the oplog is shorter than the 如果oplog短于members[n].secondaryDelaySecs
window, the delayed member cannot successfully replicate operations.members[n].secondaryDelaySecs
窗口,则延迟的成员无法成功复制操作。
When you configure a delayed member, the delay applies both to replication and to the member's oplog. 配置延迟成员时,延迟同时适用于复制和成员的oplog。For details on delayed members and their uses, see Delayed Replica Set Members.有关延迟成员及其使用的详细信息,请参阅延迟副本集成员。
The following example sets a 1-hour delay on a secondary member currently at the index 以下示例为当前位于0
in the members
array. members
数组中索引0
处的辅助成员设置1小时延迟。To set the delay, issue the following sequence of operations in a 要设置延迟,请在连接到主服务器的mongosh
session that is connected to the primary:mongosh
会话中发出以下操作序列:
cfg = rs.conf() cfg.members[0].priority = 0 cfg.members[0].hidden = true cfg.members[0].secondaryDelaySecs = 3600 rs.reconfig(cfg)
After the replica set reconfigures, the delayed secondary member cannot become primary and is hidden from applications. 副本集重新配置后,延迟的次要成员不能成为primary,并且对应用程序隐藏。The members[n].secondaryDelaySecs
value delays both replication and the member's oplog by 3600 seconds (1 hour).members[n].secondaryDelaySecs
值将复制和成员的oplog延迟3600秒(1小时)。
When updating the replica configuration object, access the replica set members in the 更新副本配置对象时,使用数组索引访问members
array with the array index. members
数组中的副本集成员。The array index begins with 数组索引以0
. 0
开头。Do not confuse this index value with the value of the 不要将此索引值与members[n]._id
field in each document in the members
array.members
数组中每个文档中的members[n]._id
字段的值混淆。
rs.reconfig()
shell method can force the current primary to step down, which causes an election.rs.reconfig()
shell方法可以强制当前的初选下台,从而导致选举。 mongod
closes all client connections. mongod
关闭所有客户端连接。