主从搭建配置可以参考一篇文章,这篇文章是基于上一篇文章开始配置的
https://www.cnblogs.com/zyp87/p/18295559
主机配置说明:
192.168.136.101 mysql01 centos7.9 2C4G 192.168.136.102 mysql02 centos7.9 2C4G 192.168.136.109 vip 防火墙主机互相放行 firewall-cmd --zone=public --permanent --add-rich-rule='rule family="ipv4" source address="192.168.136.101" accept' firewall-cmd --zone=public --permanent --add-rich-rule='rule family="ipv4" source address="192.168.136.102" accept' firewall-cmd --zone=public --permanent --add-rich-rule='rule family="ipv4" source address="192.168.136.109" accept' |
两台主机的配置都是一样,操作也一样,同步配置即可
1、获取两台主机的事务记录
show master status;
开始分别配置两个主机的从配置
CHANGE MASTER TO CHANGE MASTER TO |
2、尝试登录任意一台主机建表建库
3、安装keepalived
wget https://www.keepalived.org/software/keepalived-2.3.0.tar.gz mkdir /data01/keepalived useradd keepalived tar -zxf keepalived-2.3.0.tar.gz && cd keepalived-2.3.0 ./configure --prefix=/data01/keepalived make -j2 && make install |