keepalived 检测脑裂切换脚本
Posted wangmo
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了keepalived 检测脑裂切换脚本相关的知识,希望对你有一定的参考价值。
#!/bin/bash count=0 run1=`curl -I 192.168.30.12:8000 | grep "200 OK" | wc -l` run2=`curl -I 192.168.30.12:8020 | grep "200 OK" | wc -l` run3=`curl -I 192.168.30.12:8080 | grep "200 OK" | wc -l` run=$[$run1 + $run2 + $run3] for (( k=0; k<10; k++ )) ; do /usr/bin/mysql -uroot -p‘123456!‘ -h‘192.168.30.21‘ -e "show databases;" > /dev/null if [ $? != 0 ];then echo "mysql faild !" >> /etc/keepalived/keepalived.log break fi if [ $run -ne 3 ] ; then sleep 2 /etc/init.d/httpd start run1=`curl -I 192.168.30.12:8000 | grep "200 OK" | wc -l` run2=`curl -I 192.168.30.12:8020 | grep "200 OK" | wc -l` run3=`curl -I 192.168.30.12:8080 | grep "200 OK" | wc -l` run=$[$run1 + $run2 + $run3] count=$(($count+1)) echo "httpd start $count faild !" >> /etc/keepalived/keepalived.log else #echo "httpd start $count ok !" >> /etc/keepalived/keepalived.log break fi if [ "$count" == "9" ]; then /etc/init.d/keepalived stop echo “192.168.30.12 keepalived changed” | mail -s "keepalived changd" [email protected] echo "keepalived change !" >> /etc/keepalived/keepalived.log break fi done
以上是关于keepalived 检测脑裂切换脚本的主要内容,如果未能解决你的问题,请参考以下文章