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 复制集选举 for more
information on this situation.
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. Also, do not use the force option in any automatic
scripts and do not use force when there is still a primary.
强行应用复制集配置:
备份存活的节点。
连接进存货的节点,保存现有的配置。可以参考下列命令:
cfg=rs.conf()printjson(cfg)
在相同的成员上,通过将 members 数组的值单独设置为存活节点,删除复制集中宕机和不可达成员。考虑下面的示例,它使用了之前的步骤中创建的 cfg 变量: