搭建 MySQL 8.0 Group Replication

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了搭建 MySQL 8.0 Group Replication相关的知识,希望对你有一定的参考价值。


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 [email protected]'localhost' identified by 'mysql8.0';

CREATE USER [email protected]'%' IDENTIFIED BY 'MySQL8.0';

GRANT REPLICATION SLAVE ON *.* TO [email protected]'%';

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 8.0 Group Replication

组复制安全 | 全方位认识 MySQL 8.0 Group Replication

组复制常见疑问 | 全方位认识 MySQL 8.0 Group Replication

mysql 8.0 上的“group by desc”语法错误,在 5.7 上很好

组复制要求和限制 | 全方位认识 MySQL 8.0 Group Replication

System.TypeInitializationException: 'The type initializer for 'MySql.Data.MySqlClient.Replic