Async replication Auto failover 测试 MySQL
  IE5LYMWlmdvL 2023年11月02日 34 0

适用范围

8.0.23及以上版本

实施步骤

1.Async replication Auto failover简单说明

MySQL 8.0.22引入的Async Replication Auto failover特性,可以在同一个复制通道配置多个复制源,同一时刻只使用一个复制源,在这个复制源宕掉后可以自动使用剩余的复制源继续进行复制。

2.配置图说明

Async replication Auto failover 测试 MySQL_Async Replication


配置复制源为MGR的3个节点,在MGR每个节点宕掉后,可以自动进行切换新的复制源进行同步,下面进行具体的测试

3.准备MGR环境

mgr安装请参考《MySQL 8.0.31 单机部署3节点mgr并使用mysqlsh接管》
https://support.enmotech.com/article/publish/4141

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 | 366f4d9e-5051-11ed-b4e6-0050568aa1b4 | 172.20.23.4 |        3307 | ONLINE       | PRIMARY     | 8.0.31         | XCom                       |
| group_replication_applier | 3bf41a79-5051-11ed-b8e6-0050568aa1b4 | 172.20.23.4 |        3308 | ONLINE       | SECONDARY   | 8.0.31         | XCom                       |
| group_replication_applier | ee8ff7f2-59b8-11ed-ab1e-0050568aa1b4 | 172.20.23.4 |        3306 | ONLINE       | SECONDARY   | 8.0.31         | XCom                       |
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+----------------------------+
3 rows in set (0.00 sec)

4.搭建MySQL从库

主备库安装插件:
mysql> INSTALL PLUGIN clone SONAME'mysql_clone.so';

主库:
mysql> CREATE USER repl@'%' IDENTIFIED WITH MYSQL_NATIVE_PASSWORD BY'repl123';
mysql> GRANT REPLICATION SLAVE, BACKUP_ADMIN ON *.* TO `repl`@`%`;
从库:
mysql> set global clone_valid_donor_list='172.20.23.4:3308';
mysql> clone instance from repl@172.20.23.4:3308 identified by 'repl123';

mysql> select * from performance_schema.clone_progress;
mysql> select * from performance_schema.events_stages_current;

5.添加复制通道

# mysql -u repl -proot123 -h 172.20.23.4 -P3309
mysql> CHANGE REPLICATION SOURCE TO
  SOURCE_HOST='172.20.23.4',
  SOURCE_USER='repl',
  SOURCE_PASSWORD='repl123',
  SOURCE_PORT=3308,
  SOURCE_CONNECTION_AUTO_FAILOVER=1, 
  SOURCE_AUTO_POSITION = 1,
  SOURCE_CONNECT_RETRY = 5,
  SOURCE_RETRY_COUNT = 3
  FOR CHANNEL 'mgr-to-slave' ;

- SOURCE_CONNECTION_AUTO_FAILOVER=1  #这里是关键,表示开启自动故障转移
- SOURCE_CONNECT_RETRY =5            #表示每次重试间隔5秒,默认是60秒
- SOURCE_RETRY_COUNT =3              #表示最多重试3次,默认是是86400次

mysql> 
mysql> SELECT * FROM performance_schema.replication_applier_status\G
*************************** 1. row ***************************
              CHANNEL_NAME: group_replication_applier
             SERVICE_STATE: OFF
           REMAINING_DELAY: NULL
COUNT_TRANSACTIONS_RETRIES: 0
*************************** 2. row ***************************
              CHANNEL_NAME: group_replication_recovery
             SERVICE_STATE: OFF
           REMAINING_DELAY: NULL
COUNT_TRANSACTIONS_RETRIES: 0
*************************** 3. row ***************************
              CHANNEL_NAME: mgr-to-slave
             SERVICE_STATE: OFF
           REMAINING_DELAY: NULL
COUNT_TRANSACTIONS_RETRIES: 0
3 rows in set (0.00 sec)

6.为复制通道添加多个复制源

# mysql -u repl -proot123 -h 172.20.23.4 -P3309
mysql> SELECT asynchronous_connection_failover_add_source('mgr-to-slave','172.20.23.4',3306,null,90); 
mysql> SELECT asynchronous_connection_failover_add_source('mgr-to-slave','172.20.23.4',3307,null,80); 
mysql> SELECT asynchronous_connection_failover_add_source('mgr-to-slave','172.20.23.4',3308,null,70); 

查看复制源:
mysql> SELECT * FROM performance_schema.replication_asynchronous_connection_failover;
+--------------+-------------+------+-------------------+--------+--------------+
| CHANNEL_NAME | HOST        | PORT | NETWORK_NAMESPACE | WEIGHT | MANAGED_NAME |
+--------------+-------------+------+-------------------+--------+--------------+
| mgr-to-slave | 172.20.23.4 | 3306 |                   |     90 |              |
| mgr-to-slave | 172.20.23.4 | 3307 |                   |     80 |              |
| mgr-to-slave | 172.20.23.4 | 3308 |                   |     70 |              |
+--------------+-------------+------+-------------------+--------+--------------+
3 rows in set (0.00 sec)

Weight高的值更倾向于被选为复制源;比如172.20.23.4 3306 停止后,会使用172.20.23.4 3307作为复制源;在172.20.23.4 3306 重新启动后,由于3306对应的权重跟高,复制通道会重新切换到3306。

7.开启复制

# mysql -u repl -proot123 -h 172.20.23.4 -P3309
mysql> start replica for channel 'mgr-to-slave';
Query OK, 0 rows affected (0.01 sec)
mysql> show replica status for channel 'mgr-to-slave'\G
*************************** 1. row ***************************
             Replica_IO_State: Waiting for source to send event
                  Source_Host: 172.20.23.4
                  Source_User: repl
                  Source_Port: 3306
                Connect_Retry: 5
              Source_Log_File: binlog.000010
          Read_Source_Log_Pos: 387643
               Relay_Log_File: zCloud-Proxy-Ex-relay-bin-mgr@002dto@002dslave.000008
                Relay_Log_Pos: 4051
        Relay_Source_Log_File: binlog.000010
           Replica_IO_Running: Yes
          Replica_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Source_Log_Pos: 387643
              Relay_Log_Space: 49586
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Source_SSL_Allowed: No
           Source_SSL_CA_File: 
           Source_SSL_CA_Path: 
              Source_SSL_Cert: 
            Source_SSL_Cipher: 
               Source_SSL_Key: 
        Seconds_Behind_Source: 0
Source_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Source_Server_Id: 101
                  Source_UUID: ee8ff7f2-59b8-11ed-ab1e-0050568aa1b4
             Source_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
    Replica_SQL_Running_State: Replica has read all relay log; waiting for more updates
           Source_Retry_Count: 3
                  Source_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Source_SSL_Crl: 
           Source_SSL_Crlpath: 
           Retrieved_Gtid_Set: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa1:501660-502685
            Executed_Gtid_Set: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa1:1-502685:1000004-1055811:2001580-2061836
                Auto_Position: 1
         Replicate_Rewrite_DB: 
                 Channel_Name: mgr-to-slave
           Source_TLS_Version: 
       Source_public_key_path: 
        Get_Source_public_key: 0
            Network_Namespace: 
1 row in set (0.00 sec)

复制状态检查:
mysql> SELECT * FROM performance_schema.replication_connection_status\G
*************************** 1. row ***************************
                                      CHANNEL_NAME: group_replication_applier
                                        GROUP_NAME: 
                                       SOURCE_UUID: 
                                         THREAD_ID: NULL
                                     SERVICE_STATE: OFF
                         COUNT_RECEIVED_HEARTBEATS: 0
                          LAST_HEARTBEAT_TIMESTAMP: 0000-00-00 00:00:00.000000
                          RECEIVED_TRANSACTION_SET: 
                                 LAST_ERROR_NUMBER: 0
                                LAST_ERROR_MESSAGE: 
                              LAST_ERROR_TIMESTAMP: 0000-00-00 00:00:00.000000
                           LAST_QUEUED_TRANSACTION: 
 LAST_QUEUED_TRANSACTION_ORIGINAL_COMMIT_TIMESTAMP: 0000-00-00 00:00:00.000000
LAST_QUEUED_TRANSACTION_IMMEDIATE_COMMIT_TIMESTAMP: 0000-00-00 00:00:00.000000
     LAST_QUEUED_TRANSACTION_START_QUEUE_TIMESTAMP: 0000-00-00 00:00:00.000000
       LAST_QUEUED_TRANSACTION_END_QUEUE_TIMESTAMP: 0000-00-00 00:00:00.000000
                              QUEUEING_TRANSACTION: 
    QUEUEING_TRANSACTION_ORIGINAL_COMMIT_TIMESTAMP: 0000-00-00 00:00:00.000000
   QUEUEING_TRANSACTION_IMMEDIATE_COMMIT_TIMESTAMP: 0000-00-00 00:00:00.000000
        QUEUEING_TRANSACTION_START_QUEUE_TIMESTAMP: 0000-00-00 00:00:00.000000
*************************** 2. row ***************************
                                      CHANNEL_NAME: group_replication_recovery
                                        GROUP_NAME: 
                                       SOURCE_UUID: 
                                         THREAD_ID: NULL
                                     SERVICE_STATE: OFF
                         COUNT_RECEIVED_HEARTBEATS: 0
                          LAST_HEARTBEAT_TIMESTAMP: 0000-00-00 00:00:00.000000
                          RECEIVED_TRANSACTION_SET: 
                                 LAST_ERROR_NUMBER: 0
                                LAST_ERROR_MESSAGE: 
                              LAST_ERROR_TIMESTAMP: 0000-00-00 00:00:00.000000
                           LAST_QUEUED_TRANSACTION: 
 LAST_QUEUED_TRANSACTION_ORIGINAL_COMMIT_TIMESTAMP: 0000-00-00 00:00:00.000000
LAST_QUEUED_TRANSACTION_IMMEDIATE_COMMIT_TIMESTAMP: 0000-00-00 00:00:00.000000
     LAST_QUEUED_TRANSACTION_START_QUEUE_TIMESTAMP: 0000-00-00 00:00:00.000000
       LAST_QUEUED_TRANSACTION_END_QUEUE_TIMESTAMP: 0000-00-00 00:00:00.000000
                              QUEUEING_TRANSACTION: 
    QUEUEING_TRANSACTION_ORIGINAL_COMMIT_TIMESTAMP: 0000-00-00 00:00:00.000000
   QUEUEING_TRANSACTION_IMMEDIATE_COMMIT_TIMESTAMP: 0000-00-00 00:00:00.000000
        QUEUEING_TRANSACTION_START_QUEUE_TIMESTAMP: 0000-00-00 00:00:00.000000
*************************** 3. row ***************************
                                      CHANNEL_NAME: mgr-to-slave
                                        GROUP_NAME: 
                                       SOURCE_UUID: ee8ff7f2-59b8-11ed-ab1e-0050568aa1b4
                                         THREAD_ID: 74197
                                     SERVICE_STATE: ON
                         COUNT_RECEIVED_HEARTBEATS: 41
                          LAST_HEARTBEAT_TIMESTAMP: 2022-12-19 19:52:23.277477
                          RECEIVED_TRANSACTION_SET: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa1:501660-502736
                                 LAST_ERROR_NUMBER: 0
                                LAST_ERROR_MESSAGE: 
                              LAST_ERROR_TIMESTAMP: 0000-00-00 00:00:00.000000
                           LAST_QUEUED_TRANSACTION: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa1:502736
 LAST_QUEUED_TRANSACTION_ORIGINAL_COMMIT_TIMESTAMP: 2022-12-19 19:57:02.262710
LAST_QUEUED_TRANSACTION_IMMEDIATE_COMMIT_TIMESTAMP: 2022-12-19 19:57:02.264473
     LAST_QUEUED_TRANSACTION_START_QUEUE_TIMESTAMP: 2022-12-19 19:57:02.265027
       LAST_QUEUED_TRANSACTION_END_QUEUE_TIMESTAMP: 2022-12-19 19:57:02.265071
                              QUEUEING_TRANSACTION: 
    QUEUEING_TRANSACTION_ORIGINAL_COMMIT_TIMESTAMP: 0000-00-00 00:00:00.000000
   QUEUEING_TRANSACTION_IMMEDIATE_COMMIT_TIMESTAMP: 0000-00-00 00:00:00.000000
        QUEUEING_TRANSACTION_START_QUEUE_TIMESTAMP: 0000-00-00 00:00:00.000000
3 rows in set (0.00 sec)

mysql> 
mysql> SELECT * FROM performance_schema.replication_applier_status\G
*************************** 1. row ***************************
              CHANNEL_NAME: group_replication_applier
             SERVICE_STATE: OFF
           REMAINING_DELAY: NULL
COUNT_TRANSACTIONS_RETRIES: 0
*************************** 2. row ***************************
              CHANNEL_NAME: group_replication_recovery
             SERVICE_STATE: OFF
           REMAINING_DELAY: NULL
COUNT_TRANSACTIONS_RETRIES: 0
*************************** 3. row ***************************
              CHANNEL_NAME: mgr-to-slave
             SERVICE_STATE: ON
           REMAINING_DELAY: NULL
COUNT_TRANSACTIONS_RETRIES: 0
3 rows in set (0.00 sec)

8.故障转移模拟

8.1.异常停止172.20.23.4 3306节点

# ps -ef|grep -i 'port=3306'
root      9887  9707  0 20:02 pts/4    00:00:00 grep --color=auto -i port=3306
mysql    16748     1  1 18:39 ?        00:01:07 /usr/local/mysql/bin/mysqld --port=3306 --server-id=101 --user=mysql --datadir=/data/mysql/mysql3306 --socket=/data/mysql/mysql3306/mysql.sock --log_error=/data/mysql/mysql3306/mysqld.err --skip_name_resolve=on --gtid_mode=on --enforce_gtid_consistency=on --binlog_checksum=none --mysqlx_port=33060 --mysqlx_socket=/data/mysql/mysql3306/mysqlx.sock --plugin_load_add=group_replication.so --group_replication_group_name=aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa1 --group_replication_local_address=172.20.23.4:33061 --group_replication_group_seeds=172.20.23.4:33061,172.20.23.4:33071,172.20.23.4:33081 --report_host=172.20.23.4 --group_replication_start_on_boot=off
# 
# kill -9 16748

8.2.登录3309检查

重试了3次后,重新选择了复制源172.20.23.4 3307,符合预期
# tail -f mysqld.err
2022-12-19T12:02:52.389774Z 76397 [ERROR] [MY-010557] [Repl] Error reading packet from server for channel 'mgr-to-slave': Lost connection to MySQL server during query (server_errno=2013)
2022-12-19T12:02:52.389874Z 76397 [Warning] [MY-010897] [Repl] Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
2022-12-19T12:02:52.389987Z 76397 [ERROR] [MY-010584] [Repl] Slave I/O for channel 'mgr-to-slave': error reconnecting to master 'repl@172.20.23.4:3306' - retry-time: 5 retries: 1 message: Can't connect to MySQL server on '172.20.23.4:3306' (111), Error_code: MY-002003
2022-12-19T12:02:57.390222Z 76397 [ERROR] [MY-010584] [Repl] Slave I/O for channel 'mgr-to-slave': error reconnecting to master 'repl@172.20.23.4:3306' - retry-time: 5 retries: 2 message: Can't connect to MySQL server on '172.20.23.4:3306' (111), Error_code: MY-002003
2022-12-19T12:03:02.390526Z 76397 [ERROR] [MY-010584] [Repl] Slave I/O for channel 'mgr-to-slave': error reconnecting to master 'repl@172.20.23.4:3306' - retry-time: 5 retries: 3 message: Can't connect to MySQL server on '172.20.23.4:3306' (111), Error_code: MY-002003
2022-12-19T12:03:03.391113Z 76397 [Warning] [MY-010897] [Repl] Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
2022-12-19T12:03:03.391772Z 76397 [System] [MY-010562] [Repl] Slave I/O thread for channel 'mgr-to-slave': connected to master 'repl@172.20.23.4:3307',replication started in log 'FIRST' at position 440293
2022-12-19T12:03:03.392757Z 76397 [Warning] [MY-010549] [Repl] The master's UUID has changed, although this should not happen unless you have changed it manually. The old UUID was ee8ff7f2-59b8-11ed-ab1e-0050568aa1b4.

查看复制信息:
mysql> show replica status for channel 'mgr-to-slave'\G
*************************** 1. row ***************************
             Replica_IO_State: Waiting for source to send event
                  Source_Host: 172.20.23.4
                  Source_User: repl
                  Source_Port: 3307
                Connect_Retry: 5
              Source_Log_File: binlog.000002
          Read_Source_Log_Pos: 1726877
               Relay_Log_File: zCloud-Proxy-Ex-relay-bin-mgr@002dto@002dslave.000009
                Relay_Log_Pos: 2135
        Relay_Source_Log_File: binlog.000002
           Replica_IO_Running: Yes
          Replica_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Source_Log_Pos: 1726877
              Relay_Log_Space: 58920
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Source_SSL_Allowed: No
           Source_SSL_CA_File: 
           Source_SSL_CA_Path: 
              Source_SSL_Cert: 
            Source_SSL_Cipher: 
               Source_SSL_Key: 
        Seconds_Behind_Source: 0
Source_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Source_Server_Id: 102
                  Source_UUID: 366f4d9e-5051-11ed-b4e6-0050568aa1b4
             Source_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
    Replica_SQL_Running_State: Replica has read all relay log; waiting for more updates
           Source_Retry_Count: 3
                  Source_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Source_SSL_Crl: 
           Source_SSL_Crlpath: 
           Retrieved_Gtid_Set: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa1:501660-502806
            Executed_Gtid_Set: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa1:1-502806:1000004-1055811:2001580-2061836
                Auto_Position: 1
         Replicate_Rewrite_DB: 
                 Channel_Name: mgr-to-slave
           Source_TLS_Version: 
       Source_public_key_path: 
        Get_Source_public_key: 0
            Network_Namespace: 
1 row in set (0.00 sec)

8.3.数据同步测试

mgr环境:
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 | 366f4d9e-5051-11ed-b4e6-0050568aa1b4 | 172.20.23.4 |        3307 | ONLINE       | PRIMARY     | 8.0.31         | XCom                       |
| group_replication_applier | 3bf41a79-5051-11ed-b8e6-0050568aa1b4 | 172.20.23.4 |        3308 | ONLINE       | SECONDARY   | 8.0.31         | XCom                       |
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+----------------------------+
2 rows in set (0.00 sec)

mysql> 
mysql> select * from mgr.t;
+----+
| id |
+----+
|  0 |
| 62 |
+----+
2 rows in set (0.01 sec)
mysql> insert into mgr.t select rand()* 100;
Query OK, 1 row affected (0.00 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> select * from mgr.t;
+----+
| id |
+----+
|  0 |
| 50 |
| 62 |
+----+
3 rows in set (0.01 sec)

3309节点查看:
正常通过过来了id为50这条数据
mysql> select * from mgr.t;
+----+
| id |
+----+
|  0 |
| 50 |
| 62 |
+----+
3 rows in set (0.00 sec)

9.故障恢复后

9.1.启动172.20.23.4 3306节点

# mysqld_multi start 3306

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 | 366f4d9e-5051-11ed-b4e6-0050568aa1b4 | 172.20.23.4 |        3307 | ONLINE       | PRIMARY     | 8.0.31         | XCom                       |
| group_replication_applier | 3bf41a79-5051-11ed-b8e6-0050568aa1b4 | 172.20.23.4 |        3308 | ONLINE       | SECONDARY   | 8.0.31         | XCom                       |
| group_replication_applier | ee8ff7f2-59b8-11ed-ab1e-0050568aa1b4 | 172.20.23.4 |        3306 | ONLINE       | SECONDARY   | 8.0.31         | XCom                       |
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+----------------------------+
3 rows in set (0.00 sec)

9.2.登录3309检查

检查到3306启动后,自动转移回3306复制源,符合预期;因为3306对应的Weight更高
# tail -f mysqld.err
2022-12-19T12:14:48.448935Z 77636 [Warning] [MY-010897] [Repl] Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
2022-12-19T12:14:48.449616Z 77636 [System] [MY-010562] [Repl] Slave I/O thread for channel 'mgr-to-slave': connected to master 'repl@172.20.23.4:3306',replication started in log 'FIRST' at position 1783984
2022-12-19T12:14:48.450604Z 77636 [Warning] [MY-010549] [Repl] The master's UUID has changed, although this should not happen unless you have changed it manually. The old UUID was 366f4d9e-5051-11ed-b4e6-0050568aa1b4.

复制检查:
mysql> show replica status for channel 'mgr-to-slave'\G
*************************** 1. row ***************************
             Replica_IO_State: Waiting for source to send event
                  Source_Host: 172.20.23.4
                  Source_User: repl
                  Source_Port: 3306
                Connect_Retry: 5
              Source_Log_File: binlog.000013
          Read_Source_Log_Pos: 76261
               Relay_Log_File: zCloud-Proxy-Ex-relay-bin-mgr@002dto@002dslave.000010
                Relay_Log_Pos: 13493
        Relay_Source_Log_File: binlog.000013
           Replica_IO_Running: Yes
          Replica_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Source_Log_Pos: 75811
              Relay_Log_Space: 73265
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Source_SSL_Allowed: No
           Source_SSL_CA_File: 
           Source_SSL_CA_Path: 
              Source_SSL_Cert: 
            Source_SSL_Cipher: 
               Source_SSL_Key: 
        Seconds_Behind_Source: 0
Source_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Source_Server_Id: 101
                  Source_UUID: ee8ff7f2-59b8-11ed-ab1e-0050568aa1b4
             Source_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
    Replica_SQL_Running_State: Replica has read all relay log; waiting for more updates
           Source_Retry_Count: 3
                  Source_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Source_SSL_Crl: 
           Source_SSL_Crlpath: 
           Retrieved_Gtid_Set: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa1:501660-502971
            Executed_Gtid_Set: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa1:1-502971:1000004-1055811:2001580-2061836
                Auto_Position: 1
         Replicate_Rewrite_DB: 
                 Channel_Name: mgr-to-slave
           Source_TLS_Version: 
       Source_public_key_path: 
        Get_Source_public_key: 0
            Network_Namespace: 
1 row in set (0.00 sec)

9.3.数据同步测试

mgr环境:
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 | 366f4d9e-5051-11ed-b4e6-0050568aa1b4 | 172.20.23.4 |        3307 | ONLINE       | PRIMARY     | 8.0.31         | XCom                       |
| group_replication_applier | 3bf41a79-5051-11ed-b8e6-0050568aa1b4 | 172.20.23.4 |        3308 | ONLINE       | SECONDARY   | 8.0.31         | XCom                       |
| group_replication_applier | ee8ff7f2-59b8-11ed-ab1e-0050568aa1b4 | 172.20.23.4 |        3306 | ONLINE       | SECONDARY   | 8.0.31         | XCom                       |
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+----------------------------+
3 rows in set (0.00 sec)

mysql> 
mysql> select * from mgr.t;
+----+
| id |
+----+
|  0 |
| 50 |
| 62 |
+----+
3 rows in set (0.01 sec)
mysql> insert into mgr.t select rand()* 100;
Query OK, 1 row affected (0.00 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> select * from mgr.t;
+----+
| id |
+----+
|  0 |
| 50 |
| 62 |
| 73 |
+----+
4 rows in set (0.00 sec)


3309节点查看:
正常通过过来了id为73这条数据
mysql> select * from mgr.t;
+----+
| id |
+----+
|  0 |
| 50 |
| 62 |
| 73 |
+----+
4 rows in set (0.00 sec)

参考文档

https://mp.weixin.qq.com/s?__biz=MzkzMTIzMDgwMg==&mid=2247484811&idx=1&sn=358720bef3f9150c2c0a6060fa4b3e0b&chksm=c26f60b6f518e9a0dc344f445d4da69e3eb0a8b42c2713dddd0963fc0d5f13a508d77d669de4&scene=178&cur_album_id=1835785426880512003#rd
【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  xaeiTka4h8LY   2024年05月31日   37   0   0 MySQL索引
  xaeiTka4h8LY   2024年05月31日   52   0   0 MySQLSQL
  xaeiTka4h8LY   2024年05月31日   31   0   0 字段MySQL
  xaeiTka4h8LY   2024年05月31日   46   0   0 MySQL数据库
  xaeiTka4h8LY   2024年05月17日   50   0   0 MySQLgithub
  xaeiTka4h8LY   2024年05月17日   38   0   0 MySQL数据库
IE5LYMWlmdvL