ab复制(gtid)配置-爱代码爱编程
两台机器做(主:master,从:slave,版本:5.7)
1.域名解析
vim /etc/hosts
格式如下图:
2.关闭防火墙和selinux:
systemctl stop firewalld
systemctl disable firewalld
setenfore 0
vi /etc/selinux/config
把 SELINUX 修改为 disable
3.配置master:
# vi /etc/my.cnf
validate_password=off //修改为弱密码登录
log-bin
server-id=1
gtid_mode=ON
enforce_gtid_consistency=1
mysql> grant replication slave,super,reload on *.* to slave@'%' identified by '数据库密码'; //授权远程账户登录
mysql> flush privileges; //刷新权限
4.slave配置:
vim /etc/my.cnf
validate_password=off //弱密码
log-bin
server-id=2
gtid_mode=ON
enforce_gtid_consistency=1
5.重启mysql
master:
systemctl restart mysqld
slave:
systemctl restart mysqld
6.再次配置slave:
mysql > change master to
master_host='master',
master_user='slave',
master_password='123',
master_auto_position=1;
mysql > start slave; //启动slave
mysql > show slave status\G //查看状态
注意:IO和SQL状态必须都为yes,否则不生效。