MGR 验证测试
架构:
10.0.1.111
10.0.1.147
10.0.1.192
MySQL [test]> select * from performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 9208c7e9-2300-11eb-84ce-fa163e3bdc68 | master | 3307 | ONLINE |
| group_replication_applier | 922aea0f-2300-11eb-ade9-fa163e185828 | slave1 | 3307 | ONLINE |
| group_replication_applier | 9234c4e6-2300-11eb-a184-fa163e313879 | slave2 | 3307 | ONLINE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
二、多主切换到单主
1、停止组复制
mysql> show variables like '%group_replication_enforce_update_everywhere_checks%';
+----------------------------------------------------+-------+
| Variable_name | Value |
+----------------------------------------------------+-------+
| group_replication_enforce_update_everywhere_checks | ON |
+----------------------------------------------------+-------+
1 row in set (0.01 sec)
每个节点执行:
mysql> set global group_replication_enforce_update_everywhere_checks=off;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like '%group_replication_single_primary_mode%';
+---------------------------------------+-------+
| Variable_name | Value |
+---------------------------------------+-------+
| group_replication_single_primary_mode | OFF |
+---------------------------------------+-------+
1 row in set (0.01 sec)
mysql> set global group_replication_single_primary_mode=on;
Query OK, 0 rows affected (0.00 sec)
2、择一个节点,打开 group_replication_bootstrap_group 为 on,并开启组复制,成功后再关闭
set global group_replication_bootstrap_group=on;
start group_replication;
set global group_replication_bootstrap_group=off;
另外两个节点逐一开启组复制,加入集群环境,并通过视图查看集群情况
start group_replication;
select * from performance_schema.replication_group_members;
#查看 Primary 成员
select *from performance_schema.replication_group_members where member_id =(select variable_value from performance_schema.global_status WHERE VARIABLE_NAME= 'group_replication_primary_member');