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. priority
为0的副本集成员。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.它可以很好地满足本地读取请求,但由于其延迟,它可能不是执行主要任务的理想候选。
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.有关详细信息,请参阅分布在两个或更多数据中心的副本集。
A secondary with priority 0
can function as a standby. priority 0
的辅助设备可以用作备用设备。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.备用成员保留数据的当前副本,以便能够替换不可用的成员。
In many cases, you need not set standby to priority 0. 在许多情况下,您不需要将备用设置为priority 0
。However, in replica sets with varied hardware or geographic distribution, a priority 0 standby ensures that only certain members become primary.但是,在具有不同硬件或地理分布的副本集中,priority 0
备用可以确保只有某些成员成为主要成员。
A priority 0 standby may also be valuable for some members of a set with different hardware or workload profiles. priority 0
的备用对于具有不同硬件或工作负载配置文件的集合中的某些成员也可能很有价值。In these cases, deploy a member with priority 0 so it can't become primary. 在这些情况下,部署priority 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.如果您的集合已经有七个有投票权的成员,请将该成员配置为无投票权。
When configuring a secondary to have 将辅助配置为priority 0
, consider potential failover patterns, including all possible network partitions. priority 0
时,请考虑潜在的故障转移模式,包括所有可能的网络分区。Always ensure that your main data center contains both a quorum of voting members and members that are eligible to be primary.始终确保您的主数据中心包含法定人数的投票成员和有资格成为主要成员的成员。
To configure a secondary to have 要将辅助配置为具有priority 0
, see Prevent Secondary from Becoming Primary.priority 0
,请参阅防止Secondary变为Primary。