默认情况下,组复制的组通信引擎(XCom,一种 Paxos 变体)使用复制组中的每个成员作为领导者。组通信引擎可以在组处于单主模式时使用单一领导者来推动共识。在单主模式下使用单一共识领导者可以提高性能和弹性,尤其是在组的一些辅助成员当前无法访问的情况下。By default, the group communication engine for Group Replication (XCom, a Paxos variant) operates using every member of the replication group as a leader. The group communication engine can use a single leader to drive consensus when the group is in single-primary mode. Operating with a single consensus leader improves performance and resilience in single-primary mode, particularly when some of the group’s secondary members are currently unreachable.
要使用单个共识领导者,必须将组配置如下:To use a single consensus leader, the group must be configured as follows:
该组必须处于单主模式。The group must be in single-primary mode.
group_replication_paxos_single_leader系统变量必须设置为ON。默认设置为OFF时,该功能被禁用。你必须对复制组进行完整重启(引导)才能让组复制采纳此设置的更改。Thegroup_replication_paxos_single_leadersystem variable must be set toON. With the default settingOFF, the behavior is disabled. You must carry out a full reboot of the replication group (bootstrap) for Group Replication to pick up a change to this setting.组复制通信协议版本必须设置为 8.0.27 或更高版本。使用
group_replication_get_communication_protocol()函数查看组的通信协议版本。如果使用较低的版本,组将无法使用此行为。如果所有组成员都支持,可以使用group_replication_set_communication_protocol()函数将组的通信协议设置为更高版本。MySQL InnoDB 集群会自动管理通信协议版本。有关更多信息,请参阅 第 20.5.1.4 节,“设置组的通信协议版本”。The Group Replication communication protocol version must be set to 8.0.27 or later. Use thegroup_replication_get_communication_protocol()function to view the group's communication protocol version. If a lower version is in use, the group cannot use this behavior. You can use thegroup_replication_set_communication_protocol()function to set the group's communication protocol to a higher version if all group members support it. MySQL InnoDB Cluster manages the communication protocol version automatically. For more information, see Section 20.5.1.4, “Setting a Group's Communication Protocol Version”.
当此配置启用时,组复制会指示组通信引擎使用组的主节点作为单一的领导者来推动共识。当选出新的主节点时,组复制会告诉组通信引擎改用新的主节点。如果主节点当前不可用,组通信引擎会使用其他成员作为共识领导者。性能模式表 replication_group_communication_information 显示当前的首选和实际共识领导者,首选领导者是组复制选择的领导者,实际领导者则是由组通信引擎选出的领导者。When this configuration is in place, Group Replication instructs
the group communication engine to use the group’s primary as the
single leader to drive consensus. When a new primary is elected,
Group Replication tells the group communication engine to use it
instead. If the primary is currently unhealthy, the group
communication engine uses an alternative member as the consensus
leader. The Performance Schema table
replication_group_communication_information
shows the current preferred and actual consensus leader, with the
preferred leader being Group Replication’s choice, and the
actual leader being the one selected by the group communication
engine.
如果组处于多主模式,具有较低的通信协议版本,或该行为被 group_replication_paxos_single_leader 设置禁用,则所有成员都用作领导者来推动共识。在这种情况下,Performance Schema 表 replication_group_communication_information 会显示所有成员既是首选领导者又是实际领导者。If the group is in multi-primary mode, has a lower communication
protocol version, or the behavior is disabled by the
group_replication_paxos_single_leader
setting, all members are used as leaders to drive consensus. In
this situation, the Performance Schema table
replication_group_communication_information
shows all of the members as both the preferred and actual leaders.
Performance Schema 表 replication_group_communication_information 中的 WRITE_CONSENSUS_SINGLE_LEADER_CAPABLE 列显示该组是否支持使用单一领导者,即使在被查询成员上 group_replication_paxos_single_leader 当前设置为 OFF。如果该组在启动时 group_replication_paxos_single_leader 设置为 ON,且其通信协议版本为 MySQL 8.0.27 及以上,则该列值为 1。此信息仅返回处于 ONLINE 或 RECOVERING 状态的组成员。The WRITE_CONSENSUS_SINGLE_LEADER_CAPABLE
column of the Performance Schema table
replication_group_communication_information
shows whether the group supports the use of a single leader, even
if
group_replication_paxos_single_leader
is currently set to OFF on the queried member.
The column value is 1 if the group was started with
group_replication_paxos_single_leader
set to ON, and its communication protocol
version is MySQL 8.0.27 or above. This information is returned
only for group members in ONLINE or
RECOVERING state.