翻译或纠错本页面

隐藏节点

On this page

A hidden member maintains a copy of the primary’s data set but is invisible to client applications. Hidden members are good for workloads with different usage patterns from the other members in the replica set. Hidden members must always be priority 0 members and so cannot become primary. The db.isMaster() method does not display hidden members. Hidden members, however, may vote in elections.

在下述这样拥有五个节点的复制集中,四个从节点都拥有与主节点一致的数据集,但其中的一个从节点是隐藏节点。

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

行为

读操作

客户端将不会把读请求分发到隐藏节点上,即使我们设定了 复制集读选项 。这些隐藏节点将不会收到来自应用程序的请求。我们可以将隐藏节点专用于报表节点或是备份节点。 延时节点 也应该是一个隐藏节点。

在分片集群中, mongos 将不与隐藏节点进行交流。

投票

在复制集的选举中,隐藏节点是会 参加 投票的。当关闭一个隐藏节点的时候,请确认复制集中的可用节点个数足够进行选举,以防 主节点 降职导致复制集对外不可用。

For the purposes of backups,

  • If using the MMAPv1 storage engine, you can avoid stopping a hidden member with the db.fsyncLock() and db.fsyncUnlock() operations to flush all writes and lock the mongod instance for the duration of the backup operation.

  • 在 3.2 版更改: db.fsyncLock() can ensure that the data files do not change for MongoDB instances using either the MMAPv1 or the WiredTiger storage engines, thus providing consistency for the purposes of creating backups.

    In previous MongoDB versions, db.fsyncLock() cannot guarantee a consistent set of files for low-level backups (e.g. via file copy cp, scp, tar) for WiredTiger.

补充信息

参见 MongoDB备份方案 可以获得更多有关MongoDB备份的信息。关于如何配置一个隐藏节点,可以参考 配置一个隐藏节点