环境部署centos7安装mysql-5.7.19 group-replication

Posted 黑漆茶壶

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了环境部署centos7安装mysql-5.7.19 group-replication相关的知识,希望对你有一定的参考价值。

--mysql高可用官方文档:
mysql下载地址:
https://www.mysql.com/downloads/  :下载这个:MySQL Community Server (GPL) 5.7.19版本
 
--安装参考链接:
#mysql 组复制的原理介绍:
#mysql group-replication安装部署介绍
 
安装拓扑图:
172.27.129.2 mysql-ha-s1
172.27.129.3 mysql-ha-s2
172.27.129.4 mysql-ha-s3
 
安装用户:work
安装位置:/mnt/disk01
 
#mysql-ha-s1安装
 
--安装前准备
#创建work用户
groupadd work
useradd -g work work
 
#设置hostname以及hosts
hostnamectl set-hostname mysql-ha-s1
 
#在/etc/hosts里面添加三台机器的host解析
172.27.129.2 mysql-ha-s1
172.27.129.3 mysql-ha-s2
172.27.129.4 mysql-ha-s3
 
#关闭服务器防火墙与selinux
#关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
firewall-cmd --state
 
#关闭selinux
/usr/sbin/sestatus -v
setenforce 0
sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g‘ /etc/selinux/config
 
#设置/mnt/disk01权限
chmod 777 /mnt/disk01
 
#开始安装进程
#进入work用户
su - work
tar -zxvf /home/work/mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
mv /home/work/mysql-5.7.19-linux-glibc2.12-x86_64 /home/work/mysql-5.7.19
 
#安装数据库-配置文件与数据分开存储
/home/work/mysql-5.7.19/bin/mysqld --no-defaults --initialize --explicit_defaults_for_timestamp --basedir=/mnt/disk01/mysql/ --datadir=/mnt/disk01/data
 
注:请记录安装提示中的初始密码,例如:[email protected]: sdk>cO;Rq3B+
 
#mysql配置文件内容:

[mysqld]
# server configuration
datadir=/mnt/disk01/data
basedir=/mnt/disk01/mysql
#set plugin local value
plugin_dir=/home/work/mysql-5.7.19/lib/plugin
port=24801
socket=/tmp/mysql.sock
 
# base config
server_id=1
gtid_mode=ON
user=mysql
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
 
# group replication
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= "172.27.129.2:24901"
loose-group_replication_group_seeds= "172.27.129.2:24901,172.27.129.3:24901,172.27.129.4:24901"
loose-group_replication_bootstrap_group= off
 
# open mutil_mode config
loose-group_replication_single_primary_mode=FALSE
loose-group_replication_enforce_update_everywhere_checks= TRUE

#创建配置文件
touch /mnt/disk01/mysql/my.cnf
将以上配置写入配置文件。
 
#配置mysql环境变量
vi ~/.bash_profile
在“export PATH”上一行增加如下内容:
PATH=$PATH:/home/work/mysql-5.7.19/bin
 
使配置文件生效:source ~/.bash_profile
 
#启动mysql数据库
/home/work/mysql-5.7.19/bin/mysqld --defaults-file=/mnt/disk01/mysql/my.cnf &
 
#非交互式修改初始密码
/home/work/mysql-5.7.19/bin/mysqladmin -S /tmp/mysql.sock -u root -p‘sdk>cO;Rq3B+‘ password ‘your passwd’
 
#登录数据库:
mysql -uroot -p‘your passwd’
 
#初始化与安装启动group-replication

SET SQL_LOG_BIN=0;
CREATE USER [email protected]‘%‘;
GRANT REPLICATION SLAVE ON *.* TO [email protected]‘%‘ IDENTIFIED BY ‘rpl_pass‘;
FLUSH PRIVILEGES;
SET SQL_LOG_BIN=1;
CHANGE MASTER TO MASTER_USER=‘rpl_user‘, MASTER_PASSWORD=‘rpl_pass‘ FOR CHANNEL ‘group_replication_recovery‘;
INSTALL PLUGIN group_replication SONAME ‘group_replication.so‘;
SET GLOBAL group_replication_bootstrap_group=ON;
START GROUP_REPLICATION;
SET GLOBAL group_replication_bootstrap_group=OFF;

#查询启动状态
SELECT * FROM performance_schema.replication_group_members;
 
#安装完毕
 
 #mysql-ha-s2和mysql-ha-s3安装
 
注:全程参照s1安装,有以下几点存在改变。
 
1、注意my.cnf的server_id 顺延变为2和3
2、注意my.cnf的loose-group_replication_local_address顺延
3、mysql初始化与启动脚本按照如下操作:

SET SQL_LOG_BIN=0;
CREATE USER [email protected]‘%‘;
GRANT REPLICATION SLAVE ON *.* TO [email protected]‘%‘ IDENTIFIED BY ‘rpl_pass‘;
FLUSH PRIVILEGES;
SET SQL_LOG_BIN=1;
CHANGE MASTER TO MASTER_USER=‘rpl_user‘, MASTER_PASSWORD=‘rpl_pass‘ FOR CHANNEL ‘group_replication_recovery‘;
INSTALL PLUGIN group_replication SONAME ‘group_replication.so‘;
set global group_replication_allow_local_disjoint_gtids_join=ON;
START GROUP_REPLICATION;

 
其他没有区别。
安装完成,进行测试即可。 

以上是关于环境部署centos7安装mysql-5.7.19 group-replication的主要内容,如果未能解决你的问题,请参考以下文章

产环境部署node记录: centOS 7 mySQL和mongoDB的安装

centos7安装 MySQL5.7.19

MySQL 5.7.19 CentOS 7 安装

MySQL基础CentOS 7.4 RPM方式安装MySQL 5.7.19

MySQL进阶Keepalived1.4.0结合MySQL 5.7.19实现主备高可用

windows系统mysql-5.7.19官方绿色版zip包安装教程