环境:rhel6.5 server7server8server9 #清空节点数据库数据,重新初始化
[root@server7 ~]# cd /var/lib/mysql
[root@server7 mysql]# rm -fr *
[root@server7 ~]# uuidgen
78030800-2ca8-4085-99ec-91099dbbde45
[root@server7 ~]# vim /etc/my.cnf
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

transaction_write_set_extraction=XXHASH64
loose-group_replication_group_name="78030800-2ca8-4085-99ec-91099dbbde45" #注意三个节点uuid一致否则START GROUP_REPLICATION起不来,成为单节点
loose-group_replication_start_on_boot=off
loose-group_replication_local_address= "172.25.135.7:24901" #各自改为节点IP
loose-group_replication_group_seeds= "172.25.135.7:24901,172.25.135.8:24901,172.25.135.9:24901"
loose-group_replication_bootstrap_group=off
loose-group_replication_ip_whitelist="172.25.135.0/24"
loose-group_replication_enforce_update_everywhere_checks=on
loose-group_replication_single_primary_mode=off

[root@server7 ~]# /etc/init.d/mysqld start
初始化 MySQL 数据库: [确定]
Installing validate password plugin: [确定]
正在启动 mysqld: [确定]
[root@server7 ~]# grep password /var/log/mysqld.log
[root@server7 ~]# mysql_secure_installation #初始化
[root@server7 ~]# mysql -pCaonimei@478
mysql> SET SQL_LOG_BIN=0;
mysql> GRANT REPLICATION SLAVE ON . TO rpl_user@'%' IDENTIFIED BY 'Caonimei@478'
-> ;
mysql> FLUSH PRIVILEGES;
mysql> reset master;
mysql> SET SQL_LOG_BIN=1;
mysql> CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='Caonimei@478' FOR CHANNEL 'group_replication_recovery';
mysql> INSTALL PLUGIN group_replication SONAME 'group_replication.so';
mysql> SHOW PLUGINS;
mysql> set global group_replication_bootstrap_group=ON;
mysql> start group_replication;
mysql> set global group_replication_bootstrap_group=OFF;
mysql> SELECT FROM performance_schema.replication_group_members;
msyql 全同步_第1张图片
mysql> create database test;
mysql> use test;
mysql> insert into t1 values (1, 'luis');
mysql> select
from t1;
+----+------+
| c1 | c2 |
+----+------+
| 1 | luis |
+----+------+
1 row in set (0.00 sec)
[root@server9 ~]# mysql -pCaonimei@478
mysql> SET SQL_LOG_BIN=0;
mysql> GRANT REPLICATION SLAVE ON . TO rpl_user@'%' IDENTIFIED BY 'Caonimei@478'
-> ;
mysql> FLUSH PRIVILEGES;
mysql> reset master;
mysql> SET SQL_LOG_BIN=1;
mysql> CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='Caonimei@478' FOR CHANNEL 'group_replication_recovery';
mysql> SHOW PLUGINS;
mysql> START GROUP_REPLICATION;
mysql> SELECT * FROM performance_schema.replication_group_members;
server8和server9保持一致配置:状态online即为ok
msyql 全同步_第2张图片