On this page本页内容
When reconfiguring primary-secondary-arbiter (PSA) replica sets or changing to a PSA architecture, you need to take special care in the following cases:在重新配置主辅助仲裁器(PSA)副本集或更改为PSA体系结构时,在以下情况下需要特别注意:
If the secondary you are adding is lagged and the resulting replica set is a PSA configuration, the first configuration change will change the number of nodes that need to commit a change with 如果要添加的次要副本已滞后,并且生成的副本集是PSA配置,则第一次配置更改将更改需要提交"majority"
. "majority"
更改的节点数。In this case, your commit point will lag until the secondary has caught up.在这种情况下,您的提交点将滞后,直到辅助服务器赶上。
This document outlines the procedure for reconfiguring your replica set in these specific cases without using the designated helper method 本文档概述了在这些特定情况下重新配置副本集的过程,无需使用指定的助手方法rs.reconfigForPSASet()
.rs.reconfigForPSASet()
。
If you are performing one of the preceding operations, it is necessary to reconfigure your replica set in two steps:如果要执行上述操作之一,则需要分两步重新配置副本集:
{ votes: 1, priority: 0 }
.{ votes: 1, priority: 0 }
的辅助副本。{ votes: 1, priority: <num> }
.{ votes: 1, priority: <num> }
。The two-step approach avoids the possibility of rolling back committed writes in the case of a failover to the new secondary before the new secondary has all committed writes from the previous primary.两步方法避免了在故障切换到新辅助设备时,在新辅助设备从上一个主设备完成所有已提交的写入之前回滚已提交的写操作的可能性。
To run the 要运行rs.reconfigForPSASet()
method, you must connect to the primary of the replica set.rs.reconfigForPSASet()
方法,必须连接到副本集的primary。
To avoid rolling back uncommitted writes when adding or changing a voting, data-bearing node, it is required that you add the node with 为了避免在添加或更改投票数据承载节点时回滚未提交的写入,需要先添加具有{ priority: 0 }
first.{ priority: 0 }
的节点。
In 在mongosh
, modify the replica set configuration. mongosh
中,修改副本集配置。To reconfigure an existing replica set, first retrieve the current configuration with 要重新配置现有副本集,首先使用rs.conf()
, modify the configuration document as needed, and then pass the modified document to rs.reconfig()
:rs.conf()
检索当前配置,根据需要修改配置文档,然后将修改后的文档传递给rs.reconfig()
:
cfg = rs.conf(); cfg["members"] = [ { // existing member or members }, { "_id" : <num>, // The array position of the new member in the // ``members`` array. "host" : <host>, "arbiterOnly" : false, "buildIndexes" : true, "hidden" : false, "priority" : 0, "tags" : { <tags> }, "secondaryDelaySecs" : <num>, "votes" : 1 }, { // existing member or members } ] rs.reconfig(cfg);
Once the secondary is caught up, set the prority to the desired number. 一旦第二个被占用,将比例设置为所需的数字。Before this reconfiguration succeeds, the secondary must replicate all the writes that were committed when it had zero votes. 在重新配置成功之前,辅助服务器必须复制在其拥有零票时提交的所有写入。This is automatically checked when you issue the 发出rs.reconfig()
command.rs.reconfig()
命令时,会自动检查此项。
cfg = rs.conf(); cfg["members"] = [ { // existing member or members }, { "_id" : <num>, // The array position of the new member in the // ``members`` array. "host" : <host>, "arbiterOnly" : false, "buildIndexes" : true, "hidden" : false, "priority" : <num>, "tags" : { <tags> }, "secondaryDelaySecs" : <num>, "votes" : 1 }, { // existing member or members } ] rs.reconfig(cfg);