安装主从 Mysql 5.7 # 主 mysql5.7 useradd mysql /sbin/nologin cd /usr/local tar -xvf mysql-5.7.23-linux-glibc
安装主从 Mysql 5.7
# 主 mysql5.7
useradd mysql /sbin/nologin
cd /usr/local
tar -xvf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.23-linux-glibc2.12-x86_64/ mysql
cd mysql
mkdir data conf
vim conf/my.cnf
-------------------------------------------
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
Socket=/tmp/mysql.sock
symbolic-links=0
log-error=/tmp/mysqld.log
pid-file=/usr/local/mysql/data/mysqld.pid
server-id=10
port=3388
gtid_mode=on
enforce_gtid_consistency=on
log_bin
binlog_fORMat=row
-------------------------------------------
export PATH=$PATH:/usr/local/mysql/bin
mysqld --defaults-file=/usr/local/mysql/conf/my.cnf --initialize --user=mysql
mysqld_safe --defaults-file=/usr/local/mysql/conf/my.cnf --user=mysql &
# 从 MySQL5.7
useradd mysql /sbin/nologin
cd /usr/local
tar -xvf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.23-linux-glibc2.12-x86_64/ mysql
cd mysql
mkdir data conf
vim conf/my.cnf
-------------------------------------------
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
symbolic-links=0
log-error=/tmp/mysqld.log
pid-file=/usr/local/mysql/data/mysqld.pid
server-id=20
port=3388
gtid_mode=on
enforce_gtid_consistency=on
log_bin
binlog_format=row
-------------------------------------------
export PATH=$PATH:/usr/local/mysql/bin
mysqld --defaults-file=/usr/local/mysql/conf/my.cnf --initialize --user=mysql
mysqld_safe --defaults-file=/usr/local/mysql/conf/my.cnf --user=mysql &
主从节点更改 root@'localhost' 密码和创建复制账号
set sql_log_bin=0;
alter user root@'localhost' identified by 'MySQL5.7';
create user root@'%' identified by 'MySQL5.7';
grant all on *.* to root@'%';
flush privileges;
set sql_log_bin=1;
在主节点生成测试数据
#!/bin/bash
sysbench /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua \
--mysql-host=192.168.1.225 \
--mysql-port=3388 \
--mysql-user=root \
--mysql-passWord=MySQL5.7 \
--oltp-test-mode=complex \
--oltp-tables-count=10 \
--oltp-table-size=1000000 \
--threads=10 \
--time=120 \
--report-interval=10 \
--db-driver=mysql prepare
将主节点的数据传到从节点
mysqldump -S /tmp/mysql.sock -u root -pMySQL5.7 \
--all-databases --triggers --routines --events \
--single-transaction --quick | mysql -h 192.168.1.226 -P 3388 -u root -pMySQL5.7
将从服务器指定到主服务器
change master to master_host='192.168.1.225',master_port=3388,master_user='root',master_password='MySQL5.7',master_auto_position=1;
start slave;
show slave status\G
--结束END--
本文标题: 通过 mysqldump 搭建基于 gtid MySQL 5.7 主从复制
本文链接: https://lsjlt.com/news/37843.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0