装好所有MySQL5.7, 打开GTID
修改my.cnf文件:
## group replication
transaction_write_set_extraction = XXHASH64
## 这里随机生成一个UUID,一定要是UUID
loose-group_replication_group_name = "9ac06b4e-13aa-11e7-a62e-5254004347f9"
loose-group_replication_start_on_boot = off
## 这是本机的IP,同时找一个端口
loose-group_replication_local_address = "192.168.150.131:23306"
## 这里是群组的所有机器
loose-group_replication_group_seeds = "192.168.150.131:23306,192.168.150.134:23307,192.168.150.135:23308"
loose-group_replication_bootstrap_group = off
## 这两个选项配置单主模式
loose-group_replication_single_primary_mode = true
loose-group_replication_enforce_update_everywhere_checks = false
binlog_checksum=none
所有节点上都要安装插件:
INSTALL PLUGIN group_replication SONAME 'group_replication.so';
在一台节点上执行这些命令:
SET SQL_LOG_BIN=0;
grant replication slave on *.* to repl@'%' identified by 'repl';
change master to master_user='repl',master_password='repl' for channel 'group_replication_recovery';
set global group_replication_bootstrap_group=ON;
start group_replication;
在其他的节点上执行这些命令:
SET SQL_LOG_BIN=0;
grant replication slave on *.* to repl@'%' identified by 'repl';
change master to master_user='repl',master_password='repl' for channel 'group_replication_recovery';
start group_replication;
这时在任意一个节点上执行下面的命令:
select * from performance_schema.replication_group_members;
注意,在引导节点上第一次就需要进行这个设置:
set global group_replication_bootstrap_group=ON;
但是此时默认的设置是除了引导节点之外其他节点都是非只读状态的:
set global read_only=OFF;
set global super_read_only=OFF;