Docs HomeMongoDB Manual

Hidden Replica Set Members隐藏的副本集成员

A hidden member maintains a copy of the primary's data set but is invisible to client applications. 隐藏成员维护primary数据集的副本,但对客户端应用程序不可见。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. 隐藏成员必须始终是优先级为0的成员,因此不能成为主要成员。The db.hello() method does not display hidden members. Hidden members, however, may vote in elections.db.hello()方法不显示隐藏成员。然而,隐藏成员可以在选举中投票。

In the following five-member replica set, all four secondary members have copies of the primary's data set, but one of the secondary members is hidden.在以下五个成员的复制集中,所有四个辅助成员都有主成员数据集的副本,但其中一个辅助成员是隐藏的。

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

Behavior行为

Read Operations读取操作

Clients will not distribute reads with the appropriate read preference to hidden members. 客户端不会将具有适当读取首选项的读取分发给隐藏成员。As a result, these members receive no traffic other than basic replication. 因此,除了基本复制之外,这些成员不接收任何流量。Use hidden members for dedicated tasks such as reporting and backups.将隐藏成员用于专用任务,如报告和备份。

Important

If your replica set contains delayed members ensure that the delayed members are hidden and non-voting.如果复制副本集包含延迟成员,请确保延迟成员是隐藏的并且没有投票权。

Hiding delayed replica set members prevents applications from seeing and querying delayed data without a direct connection to that member. 隐藏延迟的复制副本集成员可防止应用程序在没有直接连接到该成员的情况下查看和查询延迟的数据。Making delayed replica set members non-voting means they will not count towards acknowledging write operations with write concern "majority".使延迟的副本集成员无表决权意味着他们将不计入承认写入操作的"majority"

If you do not hide delayed members and one or more nodes become unavailable, the replica set has to wait for the delayed member and the commit point lags. A lagged commit point can lead to performance issues.如果不隐藏延迟成员,并且一个或多个节点不可用,则副本集必须等待延迟成员,提交点滞后。滞后的提交点可能会导致性能问题。

For example, consider a Primary-Secondary-Delayed replica set configuration where the delayed secondary is voting with a 10 minute delay.例如,考虑“主-辅助延迟副本集”配置,其中延迟的辅助副本以10分钟的延迟进行投票。

With one non-delayed secondary unavailable, the degraded configuration of Primary-Delayed must wait at least 10 minutes to acknowledge a write operation with "majority".在一个非延迟辅助不可用的情况下,主延迟的降级配置必须等待至少10分钟,才能用"majority"确认写入操作。The majority commit point will take longer to advance, leading to cache pressure similar performance issues with a Primary with a Secondary and an Arbiter (PSA) replica set.多数提交点将需要更长的时间才能推进,从而导致缓存压力,类似于带有辅助副本集的主副本集和仲裁器(PSA)副本集的性能问题。

For more information on the majority commit point, see Causal Consistency and Read and Write Concerns. 有关多数提交点的更多信息,请参阅因果一致性和读写入关注For additional details on resolving performance issues see the replica set maintenance tutorial.有关解决性能问题的其他详细信息,请参阅复制副本集维护教程

In a sharded cluster, mongos do not interact with hidden members.在分片集群中,mongos不与隐藏成员交互。

Voting投票

Hidden members may vote in replica set elections. 隐藏成员可以在副本集选举中投票。If you stop a voting hidden member, ensure that the set has an active majority or the primary will step down.如果您停止投票隐藏成员,请确保该组成员拥有有效多数票,否则primary将退出。

For the purposes of backups,出于备份的目的,

  • db.fsyncLock() ensures that the data files are safe to copy using low-level backup utilities such as cp, scp, or tar. 确保使用低级别备份实用程序(如cpscptar)可以安全地复制数据文件。A mongod started using the copied files contains user-written data that is indistinguishable from the user-written data on the locked mongod.使用复制文件启动的mongod包含用户写入的数据,这些数据与锁定mongod上的用户写入数据无法区分。

    The data files of a locked mongod may change due to operations such as journaling syncs or WiredTiger snapshots. While this has no affect on the logical data (e.g. data accessed by clients), some backup utilities may detect these changes and emit warnings or fail with errors. 锁定mongod的数据文件可能会因日志同步WiredTiger快照等操作而更改。虽然这对逻辑数据(例如客户端访问的数据)没有影响,但一些备份实用程序可能会检测到这些更改并发出警告或出现错误而失败。For more information on MongoDB- recommended backup utilities and procedures, see MongoDB Backup Methods.有关MongoDB推荐的备份实用程序和过程的更多信息,请参阅MongoDB备份方法

Write Concern撰写关注事项

Hidden replica set members can acknowledge write operations issued with w: <number>. 隐藏的副本集成员可以确认使用w: <number>发出的写入操作。For write operations issued with w : "majority", however, hidden members must also be voting members (i.e. members[n].votes greater than 0) to acknowledge the "majority" write operation. 但是,对于以w : "majority"发出的写入操作,隐藏成员也必须是有投票权的成员(即,members[n].votes大于0)才能确认"majority"写入操作。Non-voting replica set members (i.e. members[n].votes is 0) cannot contribute to acknowledging write operations with majority write concern.无表决权的副本集成员(即members[n].votes0)不能参与确认majority写入操作。

Further Reading进一步阅读

For more information about backing up MongoDB databases, see MongoDB Backup Methods. 有关备份MongoDB数据库的更多信息,请参阅MongoDB备份方法To configure a hidden member, see Configure a Hidden Replica Set Member.要配置隐藏成员,请参阅配置隐藏副本集成员