架构
主:172.17.100.106
从1:172.17.100.107
从2:172.17.100.108
MHA:172.17.100.120
VIP:172.17.100.119
MySQL搭建
MySQL版本:5.7.24
搭建脚本:MySQL5.7自动部署脚本
配置多机互信
# 每个节点都执行
ssh-keygen -t rsa # 一路回车
# 将公钥添加到认证文件中
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
# 并设置authorized_keys的访问权限
chmod 600 ~/.ssh/authorized_keys
# 只要在一个节点执行即可
# 这里在主库 172.17.100.106上执行
ssh 172.17.100.107 cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
ssh 172.17.100.108 cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
ssh 172.17.100.120 cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
# 分发整合后的文件到其它节点
scp ~/.ssh/authorized_keys 172.17.100.107:~/.ssh/
scp ~/.ssh/authorized_keys 172.17.100.108:~/.ssh/
scp ~/.ssh/authorized_keys 172.17.100.120:~/.ssh/
(重新来过的话执行:rm -rf /root/.ssh/ ,然后照着前面再进行配置)
搭建主从
搭建参考:MySQL基于GTID的主从搭建
并且配置成半同步:MySQL主从半同步配置