这篇文章主要讲解了“mysql 5.7+keepalived主从切换步骤是怎样的”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“mysql 5.7+keepalived主从切换步骤是怎样的”吧!
登陆从库:
mysql>stop slave;
mysql>show slave status;
mysql> reset slave all;
mysql>show master status; 记录此时从库的log_file和log_pos值
登陆主库:
修改/etc/keepalived/keepalived.conf文件
把priority 101改为priority 99,确认主库的priority值比从库小
#/etc/init.d/keepalived stop
在从库上确认虚拟IP是否漂移过去,用ip address命令确认
然后
mysql>change master to master_host='从库ip',master_user='slave',master_password='123456',master_log_file='从库当时记录的log_file',master_log_pos=从库当时记录的log_pos值,master_connect_retry=10;
start slave;
show slave status;
启动keepalived:
#/etc/init.d/keepalived start
感谢各位的阅读,以上就是“mysql 5.7+keepalived主从切换步骤是怎样的”的内容了,经过本文的学习后,相信大家对mysql 5.7+keepalived主从切换步骤是怎样的这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!