6.4 MySQL一主多从(级联复制)

架构图:

 

 Master配置

基础配置:
centos7.6 
firewalld:disabled
selinux:disabled
mysql:5.7.13
Master配置:
1.开启二进制日志
log_bin=/var/lib/mysql/log_bin
binlog_format=MIXED
2.修改server-id
server-id=1
3.建立授权账号
grant replication slave on *.* to 'rep'@'10.211.55.5' identified by 'S123456';
4.查看数据库状态
show master status;
查看binlog文件和 position

Slave1配置

1.开启二进制日志
log_bin=/var/lib/mysql/log_bin
binlog_format=MIXED
log_slave_updates=1 (必须有此参数,否则不会记录binlog日志)
2.修改server-id
server-id=2
3.建立授权账号
grant replication slave on *.* to 'rep2'@'10.211.55.6' identified by 'S123456';
4.查看数据库状态
show master status;
查看binlog文件和 position

Slave2配置

 
1.关闭二进制日志
2.修改server-id
3.执行同步

写入脚本
mysql<< EOF
change master to 
master_host='10.211.55.5', 
master_port=3306,
master_user='rep2',
master_password='123456',
master_log_file='log_bin.000005',
master_log_pos=446;
EOF

 

posted @ 2021-06-04 18:21  huakai201  阅读(137)  评论(0编辑  收藏  举报