组复制根据与组复制插件捆绑的 MySQL Server 版本进行版本控制。例如,如果某个成员运行的是 MySQL 8.4.9,那么该成员的组复制插件版本即为该版本。要检查某个组成员上的 MySQL Server 版本,请执行:Group Replication is versioned according to the MySQL Server version that the Group Replication plugin was bundled with. For example, if a member is running MySQL 8.4.9 then that is the version of the Group Replication plugin. To check the version of MySQL Server on a group member issue:
SELECT MEMBER_HOST,MEMBER_PORT,MEMBER_VERSION FROM performance_schema.replication_group_members;
+-------------+-------------+----------------+
| member_host | member_port | member_version |
+-------------+-------------+----------------+
| example.com | 3306 | 8.4.9 |
+-------------+-------------+----------------+
关于理解 MySQL Server 版本和选择版本的指导,请参见 第 2.1.2 节,“选择安装哪个 MySQL 版本和发行版”。For guidance on understanding the MySQL Server version and selecting a version, see Section 2.1.2, “Which MySQL Version and Distribution to Install”.
为了获得最佳的兼容性和性能,组中的所有成员应运行相同版本的 MySQL 服务器,因此也应运行相同版本的组复制。然而,在升级在线组的过程中,为了最大化可用性,您可能需要让不同 MySQL 服务器版本的成员同时运行。根据不同版本的 MySQL 所做的更改,您可能会在此情况下遇到兼容性问题。例如,如果在主要版本之间某个功能已被弃用,那么在组中混合使用这些版本可能会导致依赖该弃用功能的成员出现故障。相反,当组中有读/写成员运行较旧版本的 MySQL 时,如果向运行较新 MySQL 版本的成员写入数据,可能会在缺少新版本引入功能的成员上引起问题。For optimal compatibility and performance, all members of a group should run the same version of MySQL Server and therefore of Group Replication. However, while you are in the process of upgrading an online group, in order to maximize availability, you might need to have members with different MySQL Server versions running at the same time. Depending on the changes made between the versions of MySQL, you could encounter incompatibilities in this situation. For example, if a feature has been deprecated between major versions, then combining the versions in a group might cause members that rely on the deprecated feature to fail. Conversely, writing to a member running a newer MySQL version while there are read/write members in the group running an older MySQL version might cause issues on members that lack functions introduced in the newer release.
为了防止此类问题,组复制包括兼容性策略,使您能够安全地在同一组中组合运行不同版本 MySQL 的成员。成员会应用这些策略来决定是否以正常方式加入组,或者以只读模式加入组,或者不加入组,这取决于哪种选择能确保加入成员和现有组成员的安全运行。在升级场景中,每个服务器必须离开组,进行升级,然后以新版本服务器重新加入组。此时,成员会应用其新服务器版本的策略,这些策略可能与它最初加入组时应用的策略有所不同。To prevent such issues, Group Replication includes compatibility policies that enable you to combine members running different versions of MySQL in the same group safely. A member applies these policies to decide whether to join the group normally, or join in read-only mode, or not join the group, depending on which choice results in the safe operation of the joining member and of the existing members of the group. In an upgrade scenario, each server must leave the group, be upgraded, and rejoin the group with its new server version. At this point the member applies the policies for its new server version, which might have changed from the policies it applied when it originally joined the group.
作为管理员,您可以通过适当地配置服务器并发出START GROUP_REPLICATION 语句,指示任何服务器尝试加入任何组。是否加入该组,或者以只读模式加入该组,由尝试加入的成员自行决定和实施。在您尝试将其添加到组后,加入的成员会接收关于当前组成员的 MySQL 服务器版本的信息,评估自身与这些成员的兼容性,并应用其自身 MySQL 服务器版本使用的策略(而非现有成员使用的策略)来决定其是否兼容。As the administrator, you can instruct any server to attempt to
join any group by configuring the server appropriately and issuing
a START GROUP_REPLICATION
statement. A decision to join or not join the group, or to join
the group in read-only mode, is made and implemented by the
joining member itself after you attempt to add it to the group.
The joining member receives information on the MySQL Server
versions of the current group members, assesses its own
compatibility with those members, and applies the policies used in
its own MySQL Server version (not the
policies used by the existing members) to decide whether it is
compatible.
加入成员在尝试加入组时所应用的兼容性策略如下:The compatibility policies that a joining member applies when attempting to join a group are as follows:
如果成员运行的 MySQL 服务器版本与现有组成员运行的最低版本相同,则成员会正常加入组。A member joins a group normally if it is running the same MySQL Server version as the lowest version that the existing group members are running.
如果成员运行的 MySQL 服务器版本高于现有组成员运行的最低版本,则成员会加入组但保持只读模式。此行为仅在组以多主模式运行时才有影响,因为在以单主模式运行的组中,新增成员无论如何默认都是只读的。A member joins a group but remains in read-only mode if it is running a higher MySQL Server version than the lowest version that the existing group members are running. This behavior only makes a difference when the group is running in multi-primary mode, because in a group that is running in single-primary mode, newly added members default to being read-only in any case.
成员在检查兼容性时会考虑软件的整个主版本.次版本.发布版本。Members take into account the entire major.minor.release version of the software when checking compatibility.
在具有使用不同 MySQL 服务器版本成员的多主模式组中,Group Replication 会自动管理成员的读/写和只读状态。如果某个成员离开组,则运行当前最低版本的成员会自动设置为读/写模式。当您使用 group_replication_switch_to_multi_primary_mode() 将以单主模式运行的组更改为多主模式运行时,Group Replication 会自动将每个成员设置为正确的模式。如果成员运行的 MySQL 服务器版本高于组中存在的最低版本,则这些成员会自动置于只读模式,而运行最低版本的成员则被置于读/写模式。In a multi-primary mode group with members that use different
MySQL Server versions, Group Replication automatically manages
members' read/write and read-only status. If a member leaves
the group, the members running the version that is now the lowest
are automatically set to read/write mode. When you change a group
that was running in single-primary mode to run in multi-primary
mode using
group_replication_switch_to_multi_primary_mode(),
Group Replication automatically sets each member to the correct
mode. Members are automatically placed in read-only mode if they
are running a higher MySQL server version than the lowest version
present in the group, and members running the lowest version are
placed in read/write mode.