mysql5.7.26二进制安装
· 搭建主从后添加新的从库,发现无法进行同步
· 搭建主从同步使用为gtid方式,可无需对主库的一个值记录,这样主要方便ansible使用
# 0.基础猪呢比:创建mysql存放目录和删除centos7自带软件,创建mysql用户
yum -y remove mariadb*
mkdir -p /application/
useradd mysql -M -s /sbin/nologin -u 1111
[root@lb02 /application]# mkdir /data/mysql/data -p
yum install -y libaio-devel
yum install perl-DBD-MySQL -y
yum install -y dos2unix
# 1. 使用二进制方式安装
mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz将此安装包上传
# 2. 解压安装包
[root@lb02 ~]# tar xf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz -C /application/
# 3. 将安装包重命名
[root@lb02 /application]# mv mysql-5.7.26-linux-glibc2.12-x86_64/ mysql-5.7
# 4. 创建软连接
[root@lb02 /application]# ln -s mysql-5.7/ mysql
# 5. 环境变量
[root@lb02 /application]# echo "export PATH=/application/mysql/bin:$PATH" >> /etc/profile
[root@lb02 /application]# source /etc/profile
# 6.授权目录
[root@lb02 /application]# chown -R mysql.mysql /application/*
[root@lb02 /application]# chown -R mysql.mysql /data/mysql/data
# 7. 初始化
[root@lb02 /application]# cd /application/mysql/support-files && mysqld --initialize-insecure --user=mysql --basedir=/application/mysql --datadir=/data/mysql/data
# 8. 支持使用service方式启动mysql
cp mysql.server /etc/init.d/mysqld
# 9. 授权
mkdir -p /data/binlog/
chown -R mysql.mysql /data
# 8.书写配置文件(主)
[mysqld]
basedir=/application/mysql/
datadir=/data/mysql/data
socket=/tmp/mysql.sock
server_id=51
port=3306
secure-file-priv=/tmp
autocommit=0
log_bin=/data/binlog/mysql-bin
binlog_format=row
gtid-mode=on
enforce-gtid-consistency=true
log-slave-updates=1
[mysql]
prompt=db01 [\\d]>
###从1:
[mysqld]
basedir=/application/mysql
datadir=/data/mysql/data
socket=/tmp/mysql.sock
server_id=52
port=3306
secure-file-priv=/tmp
autocommit=0
log_bin=/data/binlog/mysql-bin
binlog_format=row
gtid-mode=on
enforce-gtid-consistency=true
log-slave-updates=1
[mysql]
prompt=db02 [\\d]>
### 从2:
[mysqld]
basedir=/application/mysql
datadir=/data/mysql/data
socket=/tmp/mysql.sock
server_id=52
port=3306
secure-file-priv=/tmp
autocommit=0
log_bin=/data/binlog/mysql-bin
binlog_format=row
gtid-mode=on
enforce-gtid-consistency=true
log-slave-updates=1
[mysql]
prompt=db02 [\\d]>
# 从3
[mysqld]
basedir=/application/mysql
datadir=/data/mysql/data
socket=/tmp/mysql.sock
server_id=53
port=3306
secure-file-priv=/tmp
autocommit=0
log_bin=/data/binlog/mysql-bin
binlog_format=row
gtid-mode=on
enforce-gtid-consistency=true
log-slave-updates=1
[mysql]
prompt=db03 [\\d]>
# 9. 启动服务
[root@lb02 /application]# service mysqld start
二进制安装MySQL5.7.26