- 解决keepalived脑裂问题解决方案
主服务器上写一个脚本
#!bin/bash
kep_eth1=192.168.100.128
while true
do
ping -c 3 -w 2 $kep_eth1 &> /dev/null
if [ `echo "$?" -ne "0" ];then
/etc/init.d/keepalived stop
echo “kep_eth 1 can’t working”
elif [ `ss -antup | grep "nginx" |wc -l` -eq "0"];then
/etc/init.d/keepalived stop
echo “nginx is stoping!”
fi
sleep 5
done
#当keepalived备服务器Eth1 因某种无法连接时则停止主keepalived服务,避免出现脑裂问题
#当主服务器监测本地nginx服务异常或关闭是则关闭本地keepalived服务避免出现脑裂问题
2.备服务器上写一个脚本
#!bin/bash
vip=192.168.200.5
while true
do
ip -a | grep "$vip"
if [ "$?" -eq "0" ];then
echo “my keepalived is working!”
fi
Done
#当备服务器本机监测到自己有VIP时则通知管理员