Priority 0 Replica Set Members优先级为0的副本集成员
On this page本页内容
A priority 0
member is a member that cannot become primary and cannot trigger elections. priority 0
的成员是不能成为primary且不能触发选举的成员。Priority 0 members can acknowledge write operations issued with write concern of 优先级为0的成员可以确认以w : <number>
. w : <number>
的写入关注发出的写入操作。For 对于"majority"
write concern, the priority 0 member must also be a voting member (i.e. members[n].votes
is greater than 0
) to acknowledge the write. "majority"
写入关注,优先级为0的成员也必须是有投票权的成员(即members[n].votes
大于0
)才能确认写入。Non-voting replica set members (i.e. 无表决权的副本集成员(即members[n].votes
is 0
) cannot contribute to acknowledging write operations with "majority"
write concern.members[n].votes
为0
)不能参与确认具有"majority"
写入关注的写入操作。
Other than the aforementioned restrictions, secondaries that have 除了上述限制之外,priority 0
function as normal secondaries: they maintain a copy of the data set, accept read operations, and vote in elections.priority 0
的辅助设备的功能与普通辅助设备相同:它们维护数据集的副本,接受读取操作,并在选举中投票。
Configuring a replica set member with 如果特定成员部署在远离主部署的数据中心,因此延迟较高,则可能需要配置priority 0
might be desired if the particular member is deployed in a data center that is distant from the main deployment and therefore has higher latency. It may serve local read requests well, but might not be an ideal candidate to perform the duties of a primary due to its latency.priority 0
的副本集成员。它可以很好地服务于本地读取请求,但由于其延迟,它可能不是执行主任务的理想候选者。
For this situation, the following diagram shows a data center on the left which hosts the primary and a secondary, and a data center on the right which hosts a secondary that has been configured to have priority 0 to prevent it from becoming primary. 对于这种情况,下图在左侧显示了一个数据中心,该数据中心承载主数据中心和一个辅助数据中心,而在右侧显示的数据中心承载的辅助数据中心已配置为优先级为0,以防止其成为主数据中心。Because of this setting, only the members in the left data center are eligible to become primary in an election.由于此设置,只有左侧数据中心的成员才有资格在选举中成为主要成员。
Compare this to the default priority for replica set members, 将此优先级与副本集成员的默认优先级(priority 1
, where either of the secondaries in this scenario would be eligible to serve as primary. priority 1
)进行比较,在这种情况下,任何一个辅助都有资格充当主副本集成员。See Replica Sets Distributed Across Two or More Data Centers for more information.有关详细信息,请参阅分布在两个或多个数据中心的副本集。
Priority 0 Members as Standbys优先级为0的成员作为备用
A secondary with priority 0
can function as a standby. In some replica sets, it might not be possible to add a new member in a reasonable amount of time. A standby member keeps a current copy of the data to be able to replace an unavailable member.priority 0
的辅助设备可以用作备用设备。在某些副本集中,可能无法在合理的时间内添加新成员。备用成员保留数据的当前副本,以便能够替换不可用的成员。
In many cases, you need not set standby to priority 0. 在许多情况下,您不需要将待机设置为优先级0。However, in replica sets with varied hardware or geographic distribution, a priority 0 standby ensures that only certain members become primary.但是,在具有不同硬件或地理分布的复制副本集中,优先级为0的备用可以确保只有某些成员成为主要成员。
A priority 0 standby may also be valuable for some members of a set with different hardware or workload profiles. 优先级0待机对于具有不同硬件或工作负载配置文件的集合中的一些成员来说也可能是有价值的。In these cases, deploy a member with priority 0 so it can't become primary. 在这些情况下,部署优先级为0的成员,使其不能成为主要成员。Also consider using an hidden member for this purpose.还可以考虑为此目的使用隐藏成员。
If your set already has seven voting members, also configure the member as non-voting.如果您的集合已经有七个有投票权的成员,也可以将该成员配置为无投票权。
Failover Considerations故障切换注意事项
When configuring a secondary to have 将辅助配置为priority 0
, consider potential failover patterns, including all possible network partitions. Always ensure that your main data center contains both a quorum of voting members and members that are eligible to be primary.priority 0
0时,请考虑潜在的故障转移模式,包括所有可能的网络分区。始终确保您的主数据中心包含法定投票成员和有资格成为主要成员的成员。
Example实例
To configure a secondary to have 要将辅助配置为priority 0
, see Prevent Secondary from Becoming Primary.priority 0
,请参阅防止辅助成为主要。