裝好全部MySQL5.7, 打開GTIDsql
修改my.cnf文件:bootstrap
## 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
全部節點上都要安裝插件:bash
INSTALL PLUGIN group_replication SONAME 'group_replication.so';ide
在一臺節點上執行這些命令:插件
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; set global group_replication_allow_local_disjoint_gtids_join=ON; start group_replication;
在其餘的節點上執行這些命令:3d
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_allow_local_disjoint_gtids_join=ON; start group_replication;
這時在任意一個節點上執行下面的命令:code
select * from performance_schema.replication_group_members;
注意,在引導節點上第一次就須要進行這個設置:orm
set global group_replication_bootstrap_group=ON;
可是此時默認的設置是除了引導節點以外其餘節點都是非只讀狀態的:blog
set global read_only=OFF; set global super_read_only=OFF;