OPTIONS
翻译或纠错本页面

复制集从节点

从节点的数据集与 主节点 中的一致。从节点将主节点上的 oplog 复制到本机,并异步的将这些操作记录应用在其自己的数据集上。每个复制集可以拥有多个从节点。

下述由三个成员组成的复制集拥有两个从节点。这些从节点将主节点上的oplog复制过来并应用在其自己的数据集上。

Diagram of a 3 member replica set that consists of a primary and two secondaries.

Diagram of a 3 member replica set that consists of a primary and two secondaries.

客户端虽然无法在从节点上进行写操作,但却可以进行读操作。阅读 复制集读选项 可以获得更多有关如何让客户端直接对复制集节点进行读操作的信息。

从节点是可以升职为主节点的。一旦现有的主节点不可用了,那么复制集将会发起 election 来选择将哪个从节点提升为新的主节点。

在拥有下述三个成员的复制集中,一旦当前主节点不可用了,就会触发选举机制,并将在剩下的从节点中选举出一个新的主节点。

Diagram of an election of a new primary. In a three member replica set with two secondaries, the primary becomes unreachable. The loss of a primary triggers an election where one of the secondaries becomes the new primary

Diagram of an election of a new primary. In a three member replica set with two secondaries, the primary becomes unreachable. The loss of a primary triggers an election where one of the secondaries becomes the new primary

参见 复制集选举 获得更多信息。

我们可以通过修改参数的方式来将从节点用于特殊的需求。例如:

  • 我们可以通过禁止从节点升职为主节点的方式来将该节点永驻为从节点或是用于冷备。参见 优先级为0的复制集成员

  • 我们可以通过禁止应用在该从节点上进行读操作的方式,来让一些需要进行流量隔离的应用在其上进行读。参见 隐藏节点

  • 我们可以通过设置 “延时备份节点” 的方式来防止诸如误删除等的误操作或是错误。参见 延时节点

ON THIS PAGE