如果一个或多个实例发生故障,则集群可能会丢失其仲裁,即投票选出新主节点的能力。当足够多的实例发生故障,以至于构成集群的大多数实例不再能够对组复制操作进行投票时,就会发生这种情况。请参阅容错。当集群丢失仲裁时,您将无法再使用该集群处理写入事务,也无法更改集群的拓扑,例如添加、重新加入或删除实例。但是,如果您有一个包含 InnoDB Cluster 元数据的实例在线,则可以使用仲裁恢复集群。这假设您可以连接到包含 InnoDB Cluster 元数据的实例,并且该实例可以联系您要用于恢复集群的其他实例。
此操作存在潜在危险,因为如果使用不当,可能会造成脑裂情况,因此应将其视为最后的手段。请绝对确保该组中没有任何分区仍在网络中的某个地方运行,但从您的位置无法访问。
连接到包含集群元数据的实例,然后使用 操作,该操作将根据Cluster.forceQuorumUsingPartitionOf(instance)instance 上的元数据恢复集群,然后将从给定实例定义的角度来看所有处于ONLINE 状态的实例添加到恢复的集群中。
mysql-js> cluster.forceQuorumUsingPartitionOf("icadmin@ic-1:3306")
Restoring replicaset 'default' from loss of quorum, by using the partition composed of [icadmin@ic-1:3306]
Please provide the password for 'icadmin@ic-1:3306': ******
Restoring the InnoDB cluster ...
The InnoDB cluster was successfully restored using the partition from the instance 'icadmin@ic-1:3306'.
WARNING: To avoid a split-brain scenario, ensure that all other members of the replicaset
are removed or joined back to the group that was restored.
如果实例未自动添加到集群中,例如,如果其设置未持久化,请使用 手动将该实例添加回集群。Cluster.rejoinInstance()
恢复的集群可能不包括,也不必包括构成原始集群的所有原始实例。例如,如果原始集群由以下五个实例组成
ic-1ic-2ic-3ic-4ic-5
并且集群遇到了脑裂情况,ic-1、ic-2 和ic-3 形成一个分区,而ic-4 和ic-5 形成另一个分区。如果您连接到ic-1 并发出 以恢复集群,则生成的集群将包含以下三个实例Cluster.forceQuorumUsingPartitionOf('icadmin@ic-1:3306')
ic-1ic-2ic-3
因为ic-1 将ic-2 和ic-3 视为ONLINE,而没有看到ic-4 和ic-5。