MGR跨IDC主备集群实现自动障转移

2023年 9月 12日 87.1k 0

1.概述

MySQL 8.0.22 开始,支持异步连接故障切换机制,在现有主从复制连接失败后,自动建立到新主的异步复制连接。

MySQL 8.0.23 开始,异步连接故障切换机制还支持组复制拓扑,通过自动监视组成员身份的更改并区分主节点和从节点,在组复制主节点故障选出新主节点后,自动建立到新主的异步复制连接。

MySQL 8.0.26 开始,组复制可以设置组成员在特定情况下采取的操作,比如成员操作 mysql_disable_super_read_only_if_primary
当选择一个新的primary时,使处于单主模式的组保持超级只读模式,这样该组只接受复制的事务,不接受来自客户端的任何直接写操作。

MySQL 8.0.27 开始,异步连接故障切换机制还允许组复制作为副本,组的主节点发生故障时,新的主节点自动重新连接到源端。新增成员操作mysql_start_failover_channels_if_primary
,默认情况下,此成员操作是启用的,当启用此成员动作时,在"CHANGE replication SOURCE TO"
语句中为复制通道设置SOURCE_CONNECTION_AUTO_FAILOVER=1
时,组复制主节点复制通道上的异步连接故障转移将激活。

2.架构

MGR B 作为 MGR A 的备份

本次测试通过搭建2套MGR作为主备集群,进行异步连接故障切换测试:

(1)当主集群MGR A 的主节点发生故障时,备集群MGR B的主节点能够实现异步故障转移,自动连接MGR A 的新主节点,主备集群同步不断开,实现数据正常同步。

(2)当备集群MGR B 的主节点发生故障时,MGR B 的新主节点能够自动启动复制通道,自动连接MGR A 主节点,主备集群同步不断开,实现数据正常同步。

(3)设置MGR B成员行为,使处于单主模式的组 MGR B 保持超级只读模式,这样该组只接受复制的事务,不接受来自客户端的任何直接写。

3.测试

本次测试基于 MySQL 8.0.31,搭建2套MGR集群(单主模式)

3.1 搭建MGR集群

MGR A:

mysql> select * from performance_schema.replication_group_members;
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST    | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION | MEMBER_COMMUNICATION_STACK |
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
| group_replication_applier | 44921323-bd95-11ed-8db5-00163e01f842 | 172.17.140.201 |        6002 | ONLINE       | SECONDARY   | 8.0.31         | XCom                       |
| group_replication_applier | 6f904c5c-bd95-11ed-bc79-00163e01f842 | 172.17.140.201 |        6003 | ONLINE       | SECONDARY   | 8.0.31         | XCom                       |
| group_replication_applier | c9e254d3-bd94-11ed-8ae9-00163e01f842 | 172.17.140.201 |        6001 | ONLINE       | PRIMARY     | 8.0.31         | XCom                       |
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
3 rows in set (0.01 sec)

MGR B:

select * from performance_schema.replication_group_members;
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST    | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION | MEMBER_COMMUNICATION_STACK |
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
| group_replication_applier | 190f4674-be4a-11ed-9452-00163ea5c598 | 172.17.140.252 |        6005 | ONLINE       | PRIMARY     | 8.0.31         | XCom                       |
| group_replication_applier | 3fa9e064-be4a-11ed-92c7-00163ea5c598 | 172.17.140.252 |        6006 | ONLINE       | SECONDARY   | 8.0.31         | XCom                       |
| group_replication_applier | 6a9691c6-be4a-11ed-8a32-00163ea5c598 | 172.17.140.252 |        6007 | ONLINE       | SECONDARY   | 8.0.31         | XCom                       |
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
3 rows in set (0.00 sec)

3.2 创建复制用户

在MGR A 的主节点创建用于复制的用户 repl_user

create user repl_user@'%' identified with mysql_native_password by 'abc123';
grant replication slave on *.* to repl_user@'%';
grant select on performance_schema.* to repl_user@'%';

注意:这里复制用户需要有 performance_schema
库的select权限,主要用于获取MGR A集群成员的状态,如果没有这个权限,将不能进行异步连接故障转移。

3.3停止MGR B的组复制

在MGR B的所有节点停止组复制,可先停止从节点,避免发生节点切换

mysql> stop group_replication;

注意:这里停止组复制是为了下一步创建异步复制通道,如果不停止复制通道,在运行正常的MGR B 的主节点执行创建复制通道的语句,会导致从节点退出组,报如下错误:

2023-03-09T14:38:51.933981+08:00 17887 [ERROR] [MY-013786] [Repl] Unable to set SOURCE_CONNECTION_AUTO_FAILOVER on a non-existent or misconfigured replication channel 'mgra_to_mgrb', please create the channel and rejoin the server to the group.
2023-03-09T14:38:51.934259+08:00 17887 [ERROR] [MY-013487] [Repl] Plugin group_replication reported: 'A message sent through the Group Replication message deliver service was not delivered successfully. The server will now leave the group. Try to add the server back to the group and check if the problem persists, or check previous messages in the log for hints of what could be the problem.'
2023-03-09T14:38:51.934704+08:00 17887 [ERROR] [MY-011712] [Repl] Plugin group_replication reported: 'The server was automatically set into read only mode after an error was detected.'
2023-03-09T14:38:55.166405+08:00 0 [System] [MY-011504] [Repl] Plugin group_replication reported: 'Group membership changed: This member has left the group.'

3.4创建异步复制通道

在MGR B的所有节点创建异步复制通道

change replication source to source_host='172.17.140.201',source_port=6001,source_user='repl_user',source_password='abc123',source_auto_position=1,source_connection_auto_failover=1,source_connect_retry=10,source_retry_count=3 for channel 'mgra_to_mgrb';

  • source_host
    :MGR A 主节点的IP
  • source_port
    :MGR A 主节点的端口
  • source_connection_auto_failover=1
    :表示开启自动故障转移功能。
  • source_connect_retry
    :指定复制副本在与源端的连接超时后重新连接尝试之间的间隔(秒)。
  • source_retry_count
    :设置复制副本在连接到源超时后进行的最大重新连接尝试次数。

3.5配置复制源

在MGR B 的主节点配置复制源

select asynchronous_connection_failover_add_managed('mgra_to_mgrb','GroupReplication','bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb','172.17.140.201',6001,'',90,50);
+-------------------------------------------------------------------------------------------------------------------------------------------------------+
| asynchronous_connection_failover_add_managed('mgra_to_mgrb','GroupReplication','bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb','172.17.140.201',6001,'',90,50) |
+-------------------------------------------------------------------------------------------------------------------------------------------------------+
| The UDF asynchronous_connection_failover_add_managed() executed successfully.                                                                         |
+-------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.02 sec)

语法:

asynchronous_connection_failover_add_managed(channel, managed_type, managed_name, host, port, network_namespace, primary_weight, secondary_weight)

参数:

  • channel
    :上面创建的复制通道名称;
  • managed_type
    :管理服务的类型,当前可传入的值必须是GroupReplication;
  • managed_name
    :管理组的识别符,即group_replication_group_name参数的值;
  • host
    :源端主机名;
  • port
    :源端端口号;
  • network_namespace
    :预留为将来使用,置空;
  • primary_weight
    :MGR主服务器的权重,值为1到100,值越大,优先级越高;
  • secondary_weight
    :MGR从服务器的权重,值为1到100,值越大,优先级越高;

3.6查看配置的用于异步连接切换的复制源

mysql> select * from performance_schema.replication_asynchronous_connection_failover;
+--------------+----------------+------+-------------------+--------+--------------------------------------+
| CHANNEL_NAME | HOST           | PORT | NETWORK_NAMESPACE | WEIGHT | MANAGED_NAME                         |
+--------------+----------------+------+-------------------+--------+--------------------------------------+
| mgra_to_mgrb | 172.17.140.201 | 6001 |                   |     50 | bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb |
+--------------+----------------+------+-------------------+--------+--------------------------------------+
1 row in set (0.00 sec)

这里只显示刚才配置的一个节点,启动异步复制通道后就能看到MGR A所有节点。

3.7启动 MGR B 组复制

在MGR B 的主节点重新引导启动组复制

# 选一个节点作为引导节点
set global group_replication_bootstrap_group=ON;
start group_replication;
set global group_replication_bootstrap_group=OFF;

# 其余节点启动组复制
start group_replication;

# 查看MGR B集群状态
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST    | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION | MEMBER_COMMUNICATION_STACK |
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
| group_replication_applier | 190f4674-be4a-11ed-9452-00163ea5c598 | 172.17.140.252 |        6005 | ONLINE       | PRIMARY     | 8.0.31         | XCom                       |
| group_replication_applier | 3fa9e064-be4a-11ed-92c7-00163ea5c598 | 172.17.140.252 |        6006 | ONLINE       | SECONDARY   | 8.0.31         | XCom                       |
| group_replication_applier | 6a9691c6-be4a-11ed-8a32-00163ea5c598 | 172.17.140.252 |        6007 | ONLINE       | SECONDARY   | 8.0.31         | XCom                       |
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
3 rows in set (0.00 sec)

3.8启动异步复制通道

在MGR B的主节点启动

mysql> start replica for channel 'mgra_to_mgrb';
mysql> show replica statusG
*************************** 1. row ***************************
             Replica_IO_State: Waiting for source to send event
                  Source_Host: 172.17.140.201
                  Source_User: repl_user
                  Source_Port: 6001
                Connect_Retry: 10
              Source_Log_File: binlog.000001
          Read_Source_Log_Pos: 2614
               Relay_Log_File: relaylog-mgra_to_mgrb.000002
                Relay_Log_Pos: 2816
        Relay_Source_Log_File: binlog.000001
           Replica_IO_Running: Yes
          Replica_SQL_Running: Yes
              Replicate_Do_DB: 

异步复制通道运行正常,至此MGR A 与 MGR B已建立主备关系,MGR A主节点与 MGR B 主节点建立异步复制通道。

3.9查看配置的用于异步连接切换的复制源

mysql> select * from performance_schema.replication_asynchronous_connection_failover;
+--------------+----------------+------+-------------------+--------+--------------------------------------+
| CHANNEL_NAME | HOST           | PORT | NETWORK_NAMESPACE | WEIGHT | MANAGED_NAME                         |
+--------------+----------------+------+-------------------+--------+--------------------------------------+
| mgra_to_mgrb | 172.17.140.201 | 6001 |                   |     90 | bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb |
| mgra_to_mgrb | 172.17.140.201 | 6002 |                   |     50 | bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb |
| mgra_to_mgrb | 172.17.140.201 | 6003 |                   |     50 | bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb |
+--------------+----------------+------+-------------------+--------+--------------------------------------+
3 rows in set (0.01 sec)

可以看到这里显示了 MGR A的所有节点信息,weight 最高的为主节点

3.10故障模拟:主集群MGR A 的主节点发生故障

(1)查看当前MGR A 信息

mysql> select * from performance_schema.replication_group_members;
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST    | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION | MEMBER_COMMUNICATION_STACK |
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
| group_replication_applier | 44921323-bd95-11ed-8db5-00163e01f842 | 172.17.140.201 |        6002 | ONLINE       | SECONDARY   | 8.0.31         | XCom                       |
| group_replication_applier | 6f904c5c-bd95-11ed-bc79-00163e01f842 | 172.17.140.201 |        6003 | ONLINE       | SECONDARY   | 8.0.31         | XCom                       |
| group_replication_applier | c9e254d3-bd94-11ed-8ae9-00163e01f842 | 172.17.140.201 |        6001 | ONLINE       | PRIMARY     | 8.0.31         | XCom                       |
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
3 rows in set (0.00 sec)

当前MGR A 主节点为 6001

(2)查看异步复制信息

登录MGR B 主节点查看

mysql> show replica statusG
*************************** 1. row ***************************
             Replica_IO_State: Waiting for source to send event
                  Source_Host: 172.17.140.201
                  Source_User: repl_user
                  Source_Port: 6001
                Connect_Retry: 10
              Source_Log_File: binlog.000001
          Read_Source_Log_Pos: 2614
               Relay_Log_File: relaylog-mgra_to_mgrb.000002
                Relay_Log_Pos: 2816
        Relay_Source_Log_File: binlog.000001
           Replica_IO_Running: Yes
          Replica_SQL_Running: Yes
              Replicate_Do_DB: 

当前MGR B主节点 连接的是 MGR A的主节点 6001

(3)模拟MGR A故障

在MGR A主节点执行切主命令,模拟MGR A主节点故障,将6002设置为新主节点

mysql> select group_replication_set_as_primary('44921323-bd95-11ed-8db5-00163e01f842');
+--------------------------------------------------------------------------+
| group_replication_set_as_primary('44921323-bd95-11ed-8db5-00163e01f842') |
+--------------------------------------------------------------------------+
| Primary server switched to: 44921323-bd95-11ed-8db5-00163e01f842         |
+--------------------------------------------------------------------------+
1 row in set (0.04 sec)

mysql> select * from performance_schema.replication_group_members;
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST    | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION | MEMBER_COMMUNICATION_STACK |
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
| group_replication_applier | 44921323-bd95-11ed-8db5-00163e01f842 | 172.17.140.201 |        6002 | ONLINE       | PRIMARY     | 8.0.31         | XCom                       |
| group_replication_applier | 6f904c5c-bd95-11ed-bc79-00163e01f842 | 172.17.140.201 |        6003 | ONLINE       | SECONDARY   | 8.0.31         | XCom                       |
| group_replication_applier | c9e254d3-bd94-11ed-8ae9-00163e01f842 | 172.17.140.201 |        6001 | ONLINE       | SECONDARY   | 8.0.31         | XCom                       |
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
3 rows in set (0.00 sec)

(4)查看异步复制信息

登录MGR B 主节点查看

mysql> show replica statusG
*************************** 1. row ***************************
             Replica_IO_State: Waiting for source to send event
                  Source_Host: 172.17.140.201
                  Source_User: repl_user
                  Source_Port: 6002
                Connect_Retry: 10
              Source_Log_File: binlog.000001
          Read_Source_Log_Pos: 3343
               Relay_Log_File: relaylog-mgra_to_mgrb.000003
                Relay_Log_Pos: 435
        Relay_Source_Log_File: binlog.000001
           Replica_IO_Running: Yes
          Replica_SQL_Running: Yes
              Replicate_Do_DB: 

可以看到MGR B主节点已经自动进行异步连接故障转移,与MGR A新主节点6002建立连接并且连接正常,在此过程中并不需要人为去操作。

3.11故障模拟:备集群MGR B 的主节点发生故障

(1)查看当前MGR B信息

mysql> select * from performance_schema.replication_group_members;
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST    | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION | MEMBER_COMMUNICATION_STACK |
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
| group_replication_applier | 190f4674-be4a-11ed-9452-00163ea5c598 | 172.17.140.252 |        6005 | ONLINE       | PRIMARY     | 8.0.31         | XCom                       |
| group_replication_applier | 3fa9e064-be4a-11ed-92c7-00163ea5c598 | 172.17.140.252 |        6006 | ONLINE       | SECONDARY   | 8.0.31         | XCom                       |
| group_replication_applier | 6a9691c6-be4a-11ed-8a32-00163ea5c598 | 172.17.140.252 |        6007 | ONLINE       | SECONDARY   | 8.0.31         | XCom                       |
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
3 rows in set (0.03 sec)

(2)查看异步复制信息

  • 登录MGR B主节点6005

mysql> show replica statusG
*************************** 1. row ***************************
             Replica_IO_State: Waiting for source to send event
                  Source_Host: 172.17.140.201
                  Source_User: repl_user
                  Source_Port: 6002
                Connect_Retry: 10
              Source_Log_File: binlog.000001
          Read_Source_Log_Pos: 3343
               Relay_Log_File: relaylog-mgra_to_mgrb.000003
                Relay_Log_Pos: 435
        Relay_Source_Log_File: binlog.000001
           Replica_IO_Running: Yes
          Replica_SQL_Running: Yes
              Replicate_Do_DB: 

当前MGR B主节点与MGR A新主节点6002 异步复制连接正常

  • 登录MGR B从节点6006

mysql> show replica statusG
*************************** 1. row ***************************
             Replica_IO_State: 
                  Source_Host: 172.17.140.201
                  Source_User: repl_user
                  Source_Port: 6001
                Connect_Retry: 10
              Source_Log_File: 
          Read_Source_Log_Pos: 4
               Relay_Log_File: relaylog-mgra_to_mgrb.000001
                Relay_Log_Pos: 4
        Relay_Source_Log_File: 
           Replica_IO_Running: No
          Replica_SQL_Running: No
              Replicate_Do_DB: 

(3)模拟MGR B主节点故障

这里不能通过对MGR B执行切主命令模拟故障,会报如下错误:

mysql> select group_replication_set_as_primary('3fa9e064-be4a-11ed-92c7-00163ea5c598');
ERROR 3910 (HY000): The function 'group_replication_set_as_primary' failed. There is a slave channel running in the group's current primary member.

我们通过停止组复制让MGR B主节点6005主动退出组,模拟故障

mysql> stop group_replication;
Query OK, 0 rows affected (11.67 sec)

(4)查看当前MGR B信息

mysql> select * from performance_schema.replication_group_members;
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST    | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION | MEMBER_COMMUNICATION_STACK |
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
| group_replication_applier | 3fa9e064-be4a-11ed-92c7-00163ea5c598 | 172.17.140.252 |        6006 | ONLINE       | PRIMARY     | 8.0.31         | XCom                       |
| group_replication_applier | 6a9691c6-be4a-11ed-8a32-00163ea5c598 | 172.17.140.252 |        6007 | ONLINE       | SECONDARY   | 8.0.31         | XCom                       |
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
2 rows in set (0.00 sec)

当前MGR B发生切主,新主节点为6006

(5)查看异步复制信息

登录MGR B新主节点6006

mysql> show replica statusG
*************************** 1. row ***************************
             Replica_IO_State: Waiting for source to send event
                  Source_Host: 172.17.140.201
                  Source_User: repl_user
                  Source_Port: 6002
                Connect_Retry: 10
              Source_Log_File: binlog.000001
          Read_Source_Log_Pos: 3343
               Relay_Log_File: relaylog-mgra_to_mgrb.000002
                Relay_Log_Pos: 395
        Relay_Source_Log_File: binlog.000001
           Replica_IO_Running: Yes
          Replica_SQL_Running: Yes
              Replicate_Do_DB: 

可以看到MGR B新主节点已经自动进行异步连接故障转移,与MGR A主节点6002建立连接并且连接正常,在此过程中并不需要人为去操作。

3.12 设置备集群MGR B为超级只读模式

配置MGR B集群所有节点为超级只读模式,避免执行误操作。默认情况下,MGR单主模式下主节点为读写模式,从节点为超级只读模式。

当一个组只是作为另一个组的备份的时候,只需要执行复制事物就可以了,不需要登录执行其他客户端事物,避免造成数据不一致的问题。因此我们可以通过 group_replication_disable_member_action()
函数设置成员操作,将备集群所有节点设置为超级只读模式,即使切主后选出新的主节点也要保持超级只读模式。

(1)查看MGR B当前成员操作

mysql> select * from replication_group_member_actions;
+------------------------------------------+------------------------+---------+----------+----------+----------------+
| name                                     | event                  | enabled | type     | priority | error_handling |
+------------------------------------------+------------------------+---------+----------+----------+----------------+
| mysql_disable_super_read_only_if_primary | AFTER_PRIMARY_ELECTION |       1 | INTERNAL |        1 | IGNORE         |
| mysql_start_failover_channels_if_primary | AFTER_PRIMARY_ELECTION |       1 | INTERNAL |       10 | CRITICAL       |
+------------------------------------------+------------------------+---------+----------+----------+----------------+
2 rows in set (0.02 sec)

(2)设置MGR B为超级只读模式

mysql> SELECT group_replication_disable_member_action("mysql_disable_super_read_only_if_primary", "AFTER_PRIMARY_ELECTION");
+---------------------------------------------------------------------------------------------------------------+
| group_replication_disable_member_action("mysql_disable_super_read_only_if_primary", "AFTER_PRIMARY_ELECTION") |
+---------------------------------------------------------------------------------------------------------------+
| OK                                                                                                            |
+---------------------------------------------------------------------------------------------------------------+
1 row in set (0.04 sec)

注意:这里执行完此函数后,不会对当前主节点产生影响,当发生切主选择出新主节点后,会将新主节点设置为超级只读模式。

(3)停止MGR B主节点

mysql> stop group_replication;
Query OK, 0 rows affected (28.54 sec)

mysql> select * from performance_schema.replication_group_members;
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST    | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION | MEMBER_COMMUNICATION_STACK |
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
| group_replication_applier | 190f4674-be4a-11ed-9452-00163ea5c598 | 172.17.140.252 |        6005 | ONLINE       | PRIMARY     | 8.0.31         | XCom                       |
| group_replication_applier | 6a9691c6-be4a-11ed-8a32-00163ea5c598 | 172.17.140.252 |        6007 | ONLINE       | SECONDARY   | 8.0.31         | XCom                       |
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
2 rows in set (0.01 sec)

MGR B新主节点为 6005

(4)查看MGR B新主节点是否进入超级只读模式

mysql> show variables like 'super_read_only';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| super_read_only | ON    |
+-----------------+-------+
1 row in set (0.05 sec)

mysql> create database tt;
ERROR 1290 (HY000): The MySQL server is running with the --super-read-only option so it cannot execute this statement

此时新主节点处于超级只读模式,不允许用户执行操作。

4.总结

通过异步连接故障切换机制,当复制连接出现问题时,不需要人工介入手动去重新建立复制连接,副本会自动进行异步故障转移与新的节点建立连接。

异步复制通道的建立只能在2个MGR集群的主节点上。

5.参考文档

1. https://dev.mysql.com/doc/refman/8.0/en/replication-asynchronous-connection-failover.html

2. https://dev.mysql.com/doc/refman/8.0/en/replication-asynchronous-connection-failover-replica.html

3. 金融应用场景下跨数据中心的MGR架构方案(1)

4. 金融应用场景下跨数据中心的MGR架构方案(2)

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论