翻译或纠错本页面

延时节点

延时节点也将从 复制集 中主节点复制数据,然而延时节点中的数据集将会比复制集中主节点的数据延后。举个例子,现在是09:52,如果延时节点延后了1小时,那么延时节点的数据集中将不会有08:52之后的操作。

由于延时节点的数据集是延时的,因此它可以帮助我们在人为误操作或是其他意外情况下恢复数据。举个例子,当应用升级失败,或是误操作删除了表和数据库时,我们可以通过延时节点进行数据恢复。

注意事项

职责

延时节点:

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

行为

Delayed members copy and apply operations from the source oplog on 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.
  • 必须 小于 oplog的存储能力。参见 Oplog大小 来获得更多oplog的信息。

分片

在分片集群中,当 平衡器 平衡器打开的时候延时节点效果有限。因为延时节点延时的复制数据段,而若在延时的时间段内进行过数据段迁移的话,复制集中的延时节点就无法为还原分片集群提供有效的帮助了。

例子

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 also hidden and is a priority 0 member.

Diagram of a 5 member replica set with a hidden delayed priority 0 member.

配置方式

A delayed member has its members[n].priority equal to 0, members[n].hidden equal to true, and its members[n].slaveDelay equal to the number of seconds of delay:

{
   "_id" : <num>,
   "host" : <hostname:port>,
   "priority" : 0,
   "slaveDelay" : <seconds>,
   "hidden" : true
}

参见 配置一个延时复制节点 获得更多有关延时节点配置的信息。

←   隐藏节点 投票节点  →