Reconfigure a Replica Set with Unavailable Members使用不可用的成员重新配置副本集
On this page本页内容
To reconfigure a replica set when a majority of members are available, use the 要在大多数成员可用时重新配置副本集,请按照副本集重新配置过程中的示例,在当前primary上使用rs.reconfig()
operation on the current primary, following the example in the Replica Set Reconfiguration Procedure.rs.reconfig()
操作。
This document provides steps for re-configuring a replica set when only a minority of members are accessible.本文档提供了在只有少数成员可访问时重新配置副本集的步骤。
You may need to use the procedure, for example, in a geographically distributed replica set, where no local group of members can reach a majority. 例如,您可能需要在地理位置分散的复制副本集中使用该过程,在该复制副本集中,任何本地成员组都无法达到多数。See Replica Set Elections for more information on this situation.有关此情况的详细信息,请参阅副本集选择。
Reconfigure by Forcing the Reconfiguration通过强制重新配置进行重新配置
This procedure lets you recover while a majority of replica set members are down or unreachable. You connect to any surviving member and use the 通过此过程,您可以在大多数复制副本集成员关闭或无法访问时进行恢复。连接到任何幸存的成员,并对force
option to the rs.reconfig()
method.rs.reconfig()
方法使用force
选项。
The force
option forces a new configuration onto the member. Use this procedure only to recover from catastrophic interruptions. Do not use force
every time you reconfigure. force
选项可将新配置强制到成员上。使用此过程仅用于从灾难性中断中恢复。不要每次重新配置时都使用force
。Also, do not use the 此外,不要在任何自动脚本中使用force
option in any automatic scripts and do not use force
when there is still a primary.force
选项,并且在仍有primary时也不要使用force
。
To force reconfiguration:要强制重新配置:
Back up a surviving member.备份幸存的成员。Connect to a surviving member and save the current configuration.连接到幸存的成员并保存当前配置。Consider the following example commands for saving the configuration:请考虑以下用于保存配置的示例命令:cfg = rs.conf()
printjson(cfg)On the same member, remove the down and unreachable members of the replica set from the在同一成员上,通过将数组设置为仅等于幸存成员,从members
array by setting the array equal to the surviving members alone.members
数组中删除副本集的已关闭和无法访问的成员。Consider the following example, which uses the考虑以下示例,该示例使用上一步中创建的cfg
variable created in the previous step:cfg
变量:cfg.members = [cfg.members[0] , cfg.members[4] , cfg.members[7]]
On the same member, reconfigure the set by using the在同一个成员上,使用rs.reconfig()
command with theforce
option set totrue
:rs.reconfig()
命令重新配置集合,force
选项设置为true
:rs.reconfig(cfg, {force : true})
This operation forces the secondary to use the new configuration.此操作将强制辅助设备使用新配置。The configuration is then propagated to all the surviving members listed in the然后将配置传播到members
array. The replica set then elects a new primary.members
数组中列出的所有幸存成员。复制副本集然后选择一个新的主副本。NoteWhen you use使用force : true
, the version number in the replica set configuration increases significantly, by tens or hundreds of thousands.force : true
时,副本集配置中的版本号会显著增加,增加数万或数十万。This is normal and designed to prevent set version collisions if you accidentally force re-configurations on both sides of a network partition and then the network partitioning ends.这是正常的,旨在防止在网络分区两侧意外强制重新配置,然后网络分区结束时发生设置版本冲突。If the failure or partition was only temporary, shut down or decommission the removed members as soon as possible.如果故障或分区只是暂时的,请尽快关闭或停用已删除的成员。