mysql mgr部署

1.mysql使用版本
mysql-8.0.18-el7-x86_64.tar.gz

2.服务器
192.168.56.105 #node1
192.168.56.106 #node2
192.168.56.107 #node3

3.mysql安装
#yum
yum install -y wget libaio
#useradd
useradd -r -s /sbin/nologin  mysql
#mkdir
mkdir -p /usr/local/mysql
mkdir -p /data/mysql/data
mkdir -p /data/mysql/logs
#修改权限
chown -R mysql:mysql /usr/local/mysql8
chown -R mysql:mysql /data/mysql
chown -R mysql:mysql /usr/local/mysql8
bin/mysqld   --defaults-file=my3306.cnf --initialize
cd /usr/local/mysql8
mysqld_safe --defaults-file=my3306.cnf --user=mysql &
mysql -uroot -p123456 -S/data/mysql/mysql.sock
alter user root@localhost identified by "123456";

4.修改配置文件
binlog_format = ROW
binlog_checksum = NONE
server_id#每个服务器都不一样
loose-group_replication_local_address#每个服务器都不一样
report_host#每个服务器都不一样

 
5.所有节点都执行
CREATE USER repl@‘%‘ IDENTIFIED BY ‘repl‘;
GRANT REPLICATION SLAVE ON *.* TO repl@‘%‘;
RESET MASTER;
CHANGE MASTER TO MASTER_USER=‘repl‘, MASTER_PASSWORD=‘repl‘ FOR CHANNEL ‘group_replication_recovery‘;

 

6.引导节点执行

任意找一节点做引导节点
SET GLOBAL group_replication_bootstrap_group=ON;
START group_replication;
SET GLOBAL group_replication_bootstrap_group=off;

 

7.其他节点执行
stop group_replication;
SET GLOBAL group_replication_bootstrap_group = OFF;
START group_replication;

8.查看各节点状态

SELECT * FROM performance_schema.replication_group_members;
## 查看当前MGR模式(单主还是多主)
SELECT @@group_replication_single_primary_mode;

 

9.单主和多主切换

#切换多主
select group_replication_switch_to_multi_primary_mode();

#切换单主
select group_replication_switch_to_multi_primary_mode();

  

mysql mgr部署

上一篇:SpringBoot整合mysql-8 遇见的bug


下一篇:Ubuntu Linux 永久挂载(mount)分区