码迷,mamicode.com
首页 > 数据库 > 详细

搭建 MySQL 8.0 Group Replication

时间:2018-06-08 17:25:38      阅读:658      评论:0      收藏:0      [点我收藏+]

标签:mysql


1、修改配置文件,添加以下内容

server_id=1

gtid_mode=ON

enforce_gtid_consistency=ON

binlog_checksum=NONE

transaction_write_set_extraction=XXHASH64

loose-group_replication_group_name="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"

loose-group_replication_start_on_boot=off

loose-group_replication_local_address= "192.168.1.249:24901"

loose-group_replication_group_seeds= "192.168.1.249:24901,192.168.1.252:24901,192.168.1.253:24901"

loose-group_replication_bootstrap_group=off

loose-group_replication_ip_whitelist="192.168.1.0/24"

# 每个节点server_id、loose-group_replication_local_address值不一样,根据IP做相应的更改 


2、添加系统名称映射

192.168.1.249 kuber01

192.168.1.252 kuber02

192.168.1.253 kuber03


3、创建账户 rpl_user,每个节点需要创建

SET SQL_LOG_BIN=0;

alter user root@'localhost' identified by 'MySQL8.0';

CREATE USER rpl_user@'%' IDENTIFIED BY 'MySQL8.0';

GRANT REPLICATION SLAVE ON *.* TO rpl_user@'%';

FLUSH PRIVILEGES;

SET SQL_LOG_BIN=1;


4、节点添加到集群

CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='MySQL8.0' FOR CHANNEL 'group_replication_recovery';


5、安装插件

INSTALL PLUGIN group_replication SONAME 'group_replication.so';


6、启动节点

# 启动第一个节点

SET GLOBAL group_replication_bootstrap_group=ON;

START GROUP_REPLICATION;

SET GLOBAL group_replication_bootstrap_group=OFF;

# 启动其他节点

START GROUP_REPLICATION;


7、查询集群成员

SELECT * FROM performance_schema.replication_group_members;


注意:集群启动失败执行以下操作

# 在失败节点执行

SELECT @@global.gtid_executed;

# 在主节点执行

SET GTID_NEXT='4e2cb39d-6af1-11e8-a65c-000c29cdfd39:1';

BEGIN;

COMMIT;

SET GTID_NEXT='AUTOMATIC';

参考文档:https://ronniethedba.wordpress.com/2017/04/22/this-member-has-more-executed-transactions-than-those-present-in-the-group/


搭建 MySQL 8.0 Group Replication

标签:mysql

原文地址:http://blog.51cto.com/linux10000/2126512

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!