MGR(MySQLGroupReplication)部署搭建测试
1. 环境说明
192.168.11.131 mgr1  主节点
192.168.11.132 mgr2  从节点
192.168.11.133 mgr3  从节点
2. 在mgr1、mgr2、mgr3上安装mysql##
(1)安装过程(略),mysql版本-5.7.32
根据官⽅⽂档,mysql配置⽂件的最低要求:
#---------- basic setting: 组复制的MySQL Server实例所需的配置设置 -----------#
server_id=1  # 注意:各节点不同
gtid_mode=ON
enforce_gtid_consistency=ON
master_info_repository=TABLE
relay_log_info_repository=TABLE
binlog_checksum=NONE
log_slave_updates=ON
log_bin=binlog
binlog_format=ROW
#---------- Storage Engines: 禁⽤⾮InnoDB存储引擎 -----------#
disabled_storage_engines="MyISAM,BLACKHOLE,FEDERATED,ARCHIVE,MEMORY"
#---------- Group Replication Settings: 组复制配置 -----------#
# 将组复制插件添加到服务器在启动时加载的插件列表中。
plugin_load_add='group_replication.so'
# 这个神奇的参数5.7.6版本引⼊,⽤于定义⼀个记录事务的算法,这个算法使⽤hash标识来记录事务。
# 如果使⽤MGR,那么这个hash值需要⽤于分布式冲突检测何处理,在64位的系统,官⽹建议设置该参数使⽤ XXHASH64 算法。
transaction_write_set_extraction=XXHASH64
# 此GROUP的名字,必须是⼀个有效的UUID,以此来区分整个内⽹⾥边的各个不的GROUP,可以使⽤SELECT UUID()⽣成。
group_replication_group_name="a60fce0f-294c-11eb-8779-005056895fb9"
# 是否随服务器启动⽽⾃动启动组复制
group_replication_start_on_boot=off
# 本地的IP地址字符串,host:port
group_replication_local_address="192.168.11.131:33061"  # 注意:各节点不同
# 设置组成员的主机名和端⼝。
# 注意:该端⼝⽤于组内成员之间内部通信,不可⽤于与app连接。
group_replication_group_seeds="192.168.11.131:33061,192.168.11.132:33061,192.168.11.133:33061"
# 指定使⽤哪个Server来引导组(这⾥指的是将此系统变量设置为ON的Server)
# 在组所有可能涉及的Server的配置⽂件中建议统⼀将此系统变量设置为OFF
group_replication_bootstrap_group=off
注意:
(a)三个节点的server_id不同;group_replication_local_address也不同(对应各节点IP和端⼝);
(b)如需必要,请将root⽤户的ip地址修改为%(启动组复制后不可再修改)。
3. mgr1上创建复制⽤户
mysql> SET SQL_LOG_BIN=0;
mysql> CREATE USER repluser@'%' IDENTIFIED BY 'replpass';
mysql> GRANT REPLICATION SLAVE ON *.* TO repluser@'%';
mysql> FLUSH PRIVILEGES;
mysql> SET SQL_LOG_BIN=1;
4. mgr1上配置mgr
mysql> CHANGE MASTER TO MASTER_USER='rpluser', MASTER_PASSWORD='replpasss' FOR CHANNEL 'group_replication_recovery';
5. mgr1上安装组复制插件
(1)有两种⽅式:
(a)在配置⽂件中指定加载插件;
(b)⼿动安装插件。
(2)配置⽂件⽅式:(本⽂采⽤的⽅式)
plugin_load_add='group_replication.so'
(3)⼿动安装插件⽅式:
mysql> INSTALL PLUGIN group_replication SONAME 'group_replication.so';
(4)检查是否安装成功
mysql> SHOW PLUGINS;
| group_replication          | ACTIVE  | GROUP REPLICATION  | group_replication.so | GPL    |
6. mgr1上引导组(⾸次启动组)
注意:默认情况下是单主模式,执⾏引导的节点为主节点,可以读写;后⾯加⼊的节点(未执⾏引导)为从节点,只读(⾃动调整参数super_read_only=on/read_only=on)。
所谓引导其实就是SET GLOBAL group_replication_bootstrap_group=ON;(可以理解为指定主节点)
mysql> SET GLOBAL group_replication_bootstrap_group=ON;
mysql> START GROUP_REPLICATION;
mysql> SET GLOBAL group_replication_bootstrap_group=OFF;
检查是否已创建组:发现组已经存在,并且有⼀个组成员,状态为ONLINE
mysql> SELECT * FROM plication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 8b4f47fe-2d32-11eb-a8cf-0050568907ba | mgr1        |        3306 | ONLINE      |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
7. mgr1上创建测试库、表,并添加数据,以测试在新节点接⼊到组中后,会同步这些数据
mysql> CREATE DATABASE test;
mysql> USE test;
mysql> CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 TEXT NOT NULL);
mysql> INSERT INTO t1 VALUES (1, 'Luis');
mysql> select * from test.t1;
+----+------+
| c1 | c2  |
+----+------+
|  1 | Luis |
+----+------+
8. 添加mgr2到组
(1)创建复制⽤户
mysql> SET SQL_LOG_BIN=0;
mysql> CREATE USER repluser@'%' IDENTIFIED BY 'replpass';
mysql> GRANT REPLICATION SLAVE ON *.* TO repluser@'%';
mysql> FLUSH PRIVILEGES;
mysql> SET SQL_LOG_BIN=1;
(2)配置mgr
mysql> CHANGE MASTER TO MASTER_USER='repluser', MASTER_PASSWORD='replpass' FOR CHANNEL 'group_replication_recovery';
(3)启动组复制: 注意由于在配置mgr1时,已经引导并创建过组,因此只需要启动组复制将mgr2加⼊到组中即可。
mysql> START GROUP_REPLICATION;
(4)检查表plication_group_members,查看组成员及状态
mysql> SELECT * FROM plication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 10a9692d-2d4c-11eb-b5f8-005056891ca6 | mgr2        |        3306 | ONLINE      |
| group_replication_applier | 8b4f47fe-2d32-11eb-a8cf-0050568907ba | mgr1        |        3306 | ONLINE      |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
(5)由于mgr2的状态时ONLINE,因此,mgr2已经追上了mgr1的事务,因此查看表test.t1。
mysql> select * from test.t1;
+----+------+
| c1 | c2  |
+----+------+
|  1 | Luis |
+----+------+
事务已经⾃动同步完成。
(6)注意:在启动组复制时出现的2个报错及解决⽅法
报错1: [ERROR] Plugin group_replication reported: 'This member has more executed transactions than those present in the group.
Local transactions: 10a9692d-2d4c-11eb-b5f8-005056891ca6:1-2 > Group transactions: 8b4f47fe-2d32-11eb-a8cf-0050568907ba:1-2, a60fce0f-294c-11eb-8779-005056895fb9:1-4'
原因:虽然该mysql是新装的,但是在修改初始密码时,开启了binlog,因此将修改密码的过程写⼊到了binlog中,因此需要清空。
解决:reset master将⼆进制⽇志清空,重新START GROUP_REPLICATION
mysql> RESET MASTER;
mysql> START GROUP_REPLICATION
报错2:2020-11-23T14:42:31.109221+08:00 46 [ERROR] Plugin group_replication reported: 'There was an error when connecting to the donor server. Please check that group_replication_recovery channel credentials          2020-11-23T14:42:31.109267+08:00 46 [ERROR] Plugin group_replication reported: 'For details please check plication_connection_status table and error log messages of Slave I/O for cha 原因:由于在配置mgr时,change master时,写错了⽤户名或者密码,因此报错。
解决:
mysql> STOP GROUP_REPLICATION;
mysql> CHANGE MASTER TO MASTER_USER='repluser', MASTER_PASSWORD='replpass' FOR CHANNEL 'group_replication_recovery';
mysql> START GROUP_REPLICATION;
9. 添加mgr3到组:与mgr2加⼊组的步骤相同
(1)创建复制⽤户
mysql> RESET MASTER;
mysql> SET SQL_LOG_BIN=0;
mysql> CREATE USER repluser@'%' IDENTIFIED BY 'replpass';
mysql> GRANT REPLICATION SLAVE ON *.* TO repluser@'%';
mysql> FLUSH PRIVILEGES;
mysql> SET SQL_LOG_BIN=1;
(2)配置mgr
mysql> CHANGE MASTER TO MASTER_USER='repluser', MASTER_PASSWORD='replpass' FOR CHANNEL 'group_replication_recovery';
(3)启动组复制: 注意由于在配置mgr1时,已经引导并创建过组,因此只需要启动组复制将mgr3加⼊到组中即可。
mysql> START GROUP_REPLICATION;
(4)检查表plication_group_members,查看组成员及状态
mysql> SELECT * FROM plication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 10a9692d-2d4c-11eb-b5f8-005056891ca6 | mgr2        |        3306 | ONLINE      |
| group_replication_applier | 8b4f47fe-2d32-11eb-a8cf-0050568907ba | mgr1        |        3306 | ONLINE      |
| group_replication_applier | a67ba921-2d4e-11eb-8c11-005056892789 | mgr3        |        3306 | ONLINE      |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
(5)由于mgr3的状态时ONLINE,因此,mgr2已经追上了mgr1的事务,因此查看表test.t1。
mysql> select * from test.t1;
+----+------+
| c1 | c2  |
+----+------+
|  1 | Luis |
+----+------+
事务已经⾃动同步完成。
10. 单主模式下,如何查看哪个服务器是主服务器?
mysql> SHOW STATUS LIKE 'group_replication_primary_member';
+----------------------------------+--------------------------------------+
| Variable_name                    | Value                                |
+----------------------------------+--------------------------------------+
| group_replication_primary_member | 8b4f47fe-2d32-11eb-a8cf-0050568907ba |
+----------------------------------+--------------------------------------+
结合命令:SELECT * FROM plication_group_members;可确定主服务器的host为mgr1。mysql> SELECT * FROM plication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | +---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 10a9692d-2d4c-11eb-b5f8-005056891ca6 | mgr2        |        3306 | ONLINE      |
| group_replication_applier | 8b4f47fe-2d32-11eb-a8cf-0050568907ba | mgr1        |        3306 | ONLINE      |
| group_replication_applier | a67ba921-2d4e-11eb-8c11-005056892789 | mgr3        |        3306 | ONLINE      |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
11. 当服务器加⼊组时,尝试次数与间隔的设置
mysql> show global variables like 'group_replication_recovery_retry_count';
+----------------------------------------+-------+
| Variable_name                          | Value |
+----------------------------------------+-------+
| group_replication_recovery_retry_count | 10    |
+----------------------------------------+-------+
1 row in set (0.10 sec)
重试次数默认次数为10,可通过设置参数group_replication_recovery_retry_count调整。
如:mysql> SET GLOBAL group_replication_recovery_retry_count=15;
mysql> show global variables like 'group_replication_recovery_reconnect_interval';
+-----------------------------------------------+-------+
mysql下载配置| Variable_name                                | Value |
+-----------------------------------------------+-------+
| group_replication_recovery_reconnect_interval | 60    |
+-----------------------------------------------+-------+
1 row in set (0.14 sec)
间隔默认为60。
12. 将单主模式切换为多主模式
(1)停⽌组复制(所有节点执⾏):
mysql> stop group_replication;
(2)单主模式设置为ON,多主模式设置为OFF
mysql> set global group_replication_single_primary_mode=OFF;
(3)在所有节点启⽤多主数据更新的严格⼀致性检查
mysql> set global group_replication_enforce_update_everywhere_checks=ON;
(4)引导,随便选择某个节点执⾏(本⽂选择mgr2)
mysql> SET GLOBAL group_replication_bootstrap_group=ON;
mysql> START GROUP_REPLICATION;
mysql> SET GLOBAL group_replication_bootstrap_group=OFF;
(5)其他节点执⾏
mysql> START GROUP_REPLICATION;
(6)查看组成员及状态
mysql> select * from plication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |    +---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 10a9692d-2d4c-11eb-b5f8-005056891ca6 | mgr2        |        3306 | ONLINE      |
| group_replication_applier | 8b4f47fe-2d32-11eb-a8cf-0050568907ba | mgr1        |        3306 | ONLINE      |
| group_replication_applier | a67ba921-2d4e-11eb-8c11-005056892789 | mgr3        |        3306 | ONLINE      |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
3 rows in set (0.00 sec)
(7)查看所有节点的read_only及supper_read_only变量,都是OFF(所有节点都可读写)
mysql> show global variables like '%read_only%';
+-----------------------+-------+
| Variable_name        | Value |
+-----------------------+-------+
| innodb_read_only      | OFF  |
| read_only            | OFF  |
| super_read_only      | OFF  |
| transaction_read_only | OFF  |
| tx_read_only          | OFF  |
+-----------------------+-------+
5 rows in set (0.04 sec)
实际测试也证实组内所有节点均可读写。
(8)多主模式下,group_replication_primary_member变量值为空。
mysql> SHOW STATUS LIKE 'group_replication_primary_member';
+----------------------------------+-------+
| Variable_name                    | Value |
+----------------------------------+-------+
| group_replication_primary_member |      |
+----------------------------------+-------+
1 row in set (0.04 sec)
13. 多主模式切换为单主模式
(1)所有节点执⾏
mysql> stop group_replication;
mysql> set global group_replication_enforce_update_everywhere_checks=OFF;
mysql> set global group_replication_single_primary_mode=ON;
(2)主节点(mgr1)执⾏
mysql> SET GLOBAL group_replication_bootstrap_group=ON;
mysql> START GROUP_REPLICATION;
mysql> SET GLOBAL group_replication_bootstrap_group=OFF;
(3)从节点(mgr2、mgr3)执⾏
mysql> START GROUP_REPLICATION;
14. 多主模式下,新节点加⼊(mgr4)
(1)新节点配置⽂件:
server_id=4
group_replication_local_address="192.168.11.134:33061"
group_replication_group_seeds="192.168.11.131:33061,192.168.11.132:33061,192.168.11.133:33061,192.168.11.134:33061"
(2)在其他三个节点(mgr1、mgr2、mgr3)执⾏(重启失效!若想持久⽣效,需要同时配置⽂件中修改。)
mysql> set global group_replication_group_seeds='192.168.11.131:33061,192.168.11.132:33061,192.168.11.133:33061,192.168.11.134:33061';
(2)创建复制⽤户
mysql> reset master;
mysql> SET SQL_LOG_BIN=0;
mysql> CREATE USER repluser@'%' IDENTIFIED BY 'replpass';
mysql> GRANT REPLICATION SLAVE ON *.* TO repluser@'%';
mysql> FLUSH PRIVILEGES;
mysql> SET SQL_LOG_BIN=1;
(3)配置mgr
mysql> set global group_replication_single_primary_mode=OFF;
mysql> set global group_replication_enforce_update_everywhere_checks=ON;
mysql> CHANGE MASTER TO MASTER_USER='repluser', MASTER_PASSWORD='replpass' FOR CHANNEL 'group_replication_recovery';
(4)启动组复制: 注意由于在配置mgr1时,已经引导并创建过组,因此只需要启动组复制将mgr3加⼊到组中即可。
mysql> START GROUP_REPLICATION;
(5)检查表plication_group_members,查看组成员及状态
mysql> SELECT * FROM plication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 10a9692d-2d4c-11eb-b5f8-005056891ca6 | mgr2        |        3306 | ONLINE      |
| group_replication_applier | 8b4f47fe-2d32-11eb-a8cf-0050568907ba | mgr1        |        3306 | ONLINE      |
| group_replication_applier | 8e5d0881-2e2e-11eb-a6ac-005056895fb9 | mgr4        |        3306 | ONLINE      |
| group_replication_applier | a67ba921-2d4e-11eb-8c11-005056892789 | mgr3        |        3306 | ONLINE      |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
4 rows in set (0.01 sec)
(6)注意:
(a)其实相对于单节点模式,其区别在于多设置了两个参数:group_replication_single_primary_mode=OFF 和  group_replication_enforce_update_everywhere_checks=ON;
(b)若想持久保存这台新加⼊组的机器的信息,需要在配置⽂件中修改group_replication_group_seeds。
15. 多主模式下,故障转移
(1)多主模式下,⼀个节点fail了,写线程可以连接到其他的节点上,因为所有节点都是读写的。
(2)⼿动kill掉mgr1的mysqld和mysqld_safe线程,发现该节点被踢出。
(a)错误⽇志:
2020-11-24T17:12:10.632391+08:00 0 [Warning] Plugin group_replication reported: 'Member with address mgr1:3306 has become unreachable.'
2020-11-24T17:12:11.620997+08:00 0 [Warning] Plugin group_replication reported: 'Members removed from the group: mgr1:3306'
2020-11-24T17:12:11.621301+08:00 0 [Note] Plugin group_replication reported: 'Group membership changed to mgr2:3306, mgr4:3306, mgr3:3306 on view 16062011996623015:13.'(b)检查表plication_group_members,查看组成员已经没有mgr1
mysql>  select * from plication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 10a9692d-2d4c-11eb-b5f8-005056891ca6 | mgr2        |        3306 | ONLINE      |
| group_replication_applier | 8e5d0881-2e2e-11eb-a6ac-005056895fb9 | mgr4        |        3306 | ONLINE      |
| group_replication_applier | a67ba921-2d4e-11eb-8c11-005056892789 | mgr3        |        3306 | ONLINE      |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
3 rows in set (0.01 sec)
(3)⼿动添加⼀部分数据,再重新启动mgr1,并将其加⼊组中:
mysql> set global group_replication_single_primary_mode=OFF;
mysql> set global group_replication_enforce_update_everywhere_checks=ON;
mysql> START GROUP_REPLICATION;
发现mgr1已经添加进组:
mysql>  select * from plication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 10a9692d-2d4c-11eb-b5f8-005056891ca6 | mgr2        |        3306 | ONLINE      |
| group_replication_applier | 8b4f47fe-2d32-11eb-a8cf-0050568907ba | mgr1        |        3306 | ONLINE      |
| group_replication_applier | 8e5d0881-2e2e-11eb-a6ac-005056895fb9 | mgr4        |        3306 | ONLINE      |
| group_replication_applier | a67ba921-2d4e-11eb-8c11-005056892789 | mgr3        |        3306 | ONLINE      |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
4 rows in set (0.00 sec)
错误⽇志:
2020-11-24T17:16:53.584056+08:00 0 [Note] Plugin group_replication reported: 'Members joined the group: mgr1:3306'
2020-11-24T17:16:53.587879+08:00 0 [Note] Plugin group_replication reported: 'Group membership changed to mgr2:3306, mgr1:3306, mgr4:3306, mgr3:3306 on view 16062011996623015:14.'
2020-11-24T17:16:55.266815+08:00 0 [Note] Plugin group_replication reported: 'The member with address mgr1:3306 was declared online within the replication group'
并且发现新添加的数据已经在mgr1上存在。
16. 单主模式下,故障转移
(1)当主节点(primary member)挂掉或者因为其他原因⽽导致unreachable,会根据⾃动选举机制选择⼀个新的主节点。
(2)⾃动选举机制的规则是什么?
⾸先会⽐较剩余各节点的group_replication_member_weight变量的值,若都是相同版本的mysql,group_replication_member_weight的值⾼的当选为新主;
如果各节点的group_replication_member_weight的值相同(默认情况下都是50),则会根据各节点的server_uuid的值进⾏字典排序,选择第⼀个为新主。
(3)⼿动kill掉主节点(mgr1)的mysqld和mysqld_safe进程,查看错误⽇志(error log),发现节点被踢出,并且已经选择出⼀个新的主(mgr2)。
2020-11-25T09:20:36.787529+08:00 0 [Warning] Plugin group_replication reported: 'Member with address mgr1:3306 has become unreachable.'
2020-11-25T09:20:37.795746+08:00 0 [Warning] Plugin group_replication reported: 'Members removed from the group: mgr1:3306'
2020-11-25T09:20:37.796055+08:00 0 [Note] Plugin group_replication reported: 'Primary server with address mgr1:3306 left the group. Electing new Primary.'
2020-11-25T09:20:37.796412+08:00 0 [Note] Plugin group_replication reported: 'A new primary with address mgr2:3306 was elected, enabling conflict detection until the new primary applies all relay logs.'    2020-11-25T09:20:37.796604+08:00 102 [Note] Plugin group_replication reported: 'This server is working as secondary member with primary member address mgr2:3306.'
2020-11-25T09:20:37.796696+08:00 0 [Note] Plugin group_replication reported: 'Group membership changed to mgr2:3306, mgr4:3306, mgr3:3306 on view 16062105035172940:5.'
(4)检查表plication_group_members,查看当前组成员及状态
mysql> select * from plication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 10a9692d-2d4c-11eb-b5f8-005056891ca6 | mgr2        |        3306 | ONLINE      |
| group_replication_applier | 8e5d0881-2e2e-11eb-a6ac-005056895fb9 | mgr4        |        3306 | ONLINE      |
| group_replication_applier | a67ba921-2d4e-11eb-8c11-005056892789 | mgr3        |        3306 | ONLINE      |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
3 rows in set (0.01 sec)
(5)查看group_replication_primary_member的值,再次确认主节点是mgr2。
mysql> show global status like '%primary%';
+----------------------------------+--------------------------------------+
| Variable_name                    | Value                                |
+----------------------------------+--------------------------------------+
| group_replication_primary_member | 10a9692d-2d4c-11eb-b5f8-005056891ca6 |
+----------------------------------+--------------------------------------+
1 row in set (0.01 sec)
(6)⼿动添加部分数据后,再次将mgr1启动,并启动组复制
(a)启动mysql(略)
(b)启动组复制
mysql> START GROUP_REPLICATION;
(c)查看组成员及状态(mgr1⼜加⼊组中,是⼀个只读节点)
mysql> select * from plication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 10a9692d-2d4c-11eb-b5f8-005056891ca6 | mgr2        |        3306 | ONLINE      |
| group_replication_applier | 8b4f47fe-2d32-11eb-a8cf-0050568907ba | mgr1        |        3306 | ONLINE      |
| group_replication_applier | 8e5d0881-2e2e-11eb-a6ac-005056895fb9 | mgr4        |        3306 | ONLINE      |
| group_replication_applier | a67ba921-2d4e-11eb-8c11-005056892789 | mgr3        |        3306 | ONLINE      |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
4 rows in set (0.01 sec)
mysql> show global status like '%primary%';
+----------------------------------+--------------------------------------+
| Variable_name                    | Value                                |
+----------------------------------+--------------------------------------+
| group_replication_primary_member | 10a9692d-2d4c-11eb-b5f8-005056891ca6 |
+----------------------------------+--------------------------------------+
1 row in set (0.01 sec)
mysql> show global variables like '%read_only';
+-----------------------+-------+
| Variable_name        | Value |
+-----------------------+-------+
| innodb_read_only      | OFF  |
| read_only            | ON    |
| super_read_only      | ON    |
| transaction_read_only | OFF  |
| tx_read_only          | OFF  |
+-----------------------+-------+
5 rows in set (0.01 sec)
17. 组复制--指定ip⽩名单
(1)如果没有显⽰指定ip⽩名单,那么⾃动允许的ip列表包含下列ip地址:(所有内⽹地址,范围⽐较⼤)
10/8 prefix      (10.0.0.0 - 10.255.255.255) - Class A
172.16/12 prefix  (172.16.0.0 - 172.31.255.255) - Class B
192.168/16 prefix (192.168.0.0 - 192.168.255.255) - Class C
127.0.0.1 - localhost for IPv4

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。