MGR添加节点主要涉及以下两个参数
group_replication_group_seeds #可以动态修改
group_replication_ip_whitelist #需要关闭实例才可以修改,不需要关闭整个集群
白名单
loose-group_replication_ip_whitelist="127.0.0.1/8,10.0.0.0/8"
10.0.0.0/8 意味着你可以添加任意以10.开头的网段到集群中,要添加的IP段必须在白名单中,不然是无法加入集群的。
如果没有添加此项,可以先关闭实例,设置该参数,然后再次启动集群;同时也更新配置文件。
一个实例一个实例地关闭修改,整个集群仍可对外提供服务;
对于单写模式,如果写节点关闭,那么MGR会切换写节点;
文章后面展示了修改白名单的步骤
MGR添加新节点的步骤
1. 确保添加节点IP段在白名单中,否则就需要先添加白名单
2. 修改group_seeds
手工修改配置文件,动态修改内存group_seeds
set global group_replication_group_seeds="db33:24901,db40:24902,db50:24903";
3. 启动新节点及组复制
start group_replication;
修改白名单示例
mysql> show variables like 'group_replication_ip_whitelist'; +--------------------------------+------------------------------------------------------------------------------------------------------------------------+ | Variable_name | Value | +--------------------------------+------------------------------------------------------------------------------------------------------------------------+ | group_replication_ip_whitelist | db33/24,db40/24,db50/24,127.0.0.1/8,10.0.0.0/8 | +--------------------------------+------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> set global group_replication_ip_whitelist="db33/24,db40/24,db50/24,10.0.0.0/8"; ERROR 3093 (HY000): The IP whitelist cannot be set while Group Replication is running mysql> stop group_replication; Query OK, 0 rows affected (9.49 sec) mysql> set global group_replication_ip_whitelist="db33/24,db40/24,db50/24,10.0.0.0/8"; Query OK, 0 rows affected (0.00 sec) mysql> start group_replication; Query OK, 0 rows affected (3.26 sec) mysql> show variables like 'group_replication_ip_whitelist'; +--------------------------------+------------------------------------------------------------------------------------------------------------+ | Variable_name | Value | +--------------------------------+------------------------------------------------------------------------------------------------------------+ | group_replication_ip_whitelist | db33/24,db40/24,db50/24,10.0.0.0/8 | +--------------------------------+------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)