keepalived

KeepAlived+MySQL实现MySQL的高可用
环境
准备2台Centos6.5的服务器
两台服务器需要做MySQL互为主从架构

在主服务器上安装keepalived
#yum -y install keepalived
编辑配置文件

vim /etc/keepalived/keepalived.conf

编写kill_keepalived.sh
#vim /root/kill_keepalived.sh
kill_keepalived.sh脚本的内容

#chmod +x /root/kill_keepalived.sh

service keepalived restart

#service iptables stop
#setenforce 0

查看主是否生成VIP
#ip a

在从服务器上安装keepalived
#yum -y install keepalived
我们可以直接复制主上的keepalived.conf配置文件修改
#scp [email protected]:/etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf

编辑备的keepalived.conf配置文件

vim /etc/keepalived/keepalived.conf

编写kill_keepalived.sh
#vim /root/kill_keepalived.sh
kill_keepalived.sh脚本的内容

#chmod +x /root/kill_keepalived.sh
#service keepalived restart
#service iptables stop
#setenforce 0
验证VIP是否漂移
停掉主的mysql
#service mysqld stop
然后查看主的VIP是否还存在发现只有164了,181的VIP已经没有了

查看备是否有VIP,发现VIP已经漂移到备主机上了

至此基于keepalived的mysql高可用配置完毕

你可能感兴趣的:(linux)