Hidden Replica Set Members隐藏副本集成员

On this page本页内容

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. db.hello()方法不显示隐藏成员。Hidden members, however, may vote in elections.然而,隐藏成员可以在选举中投票。

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上的用户写入的数据无法区分。The data files of a locked mongod may change due to operations such as journaling syncs or WiredTiger snapshots. 锁定mongod的数据文件可能会因日志同步WiredTiger快照等操作而更改。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. 虽然这对逻辑数据(例如客户端访问的数据)没有影响,但一些备份实用程序可能会检测到这些更改并发出警告或出错。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.要配置隐藏成员,请参阅配置隐藏副本集成员

←  Priority 0 Replica Set MembersDelayed Replica Set Members →