007.MySQL-Keepalived搭配脚本01
1 vim /etc/keepalived/check_MySQL.sh 2 #!/bin/bash 3 MYSQL=/usr/bin/mysql 4 MYSQL_HOST=localhost 5 MYSQL_USER=root 6 CHECK_COUNT=5 7 counter=1 8 while true 9 do 10 mysql -h $MYSQL_HOST -u $MYSQL_USER -e "show status;" >/dev/null 2>&1 11 i=$? 12 ps aux | grep mysqld | grep -v grep > /dev/null 2>&1 13 j=$? 14 if [ $i = 0 ] && [ $j = 0 ] 15 then 16 exit 0 17 else 18 if [ $i = 1 ] && [ $j = 0 ] 19 then 20 exit 0 21 else 22 if [ $counter -gt $CHECK_COUNT ] 23 then 24 break 25 fi 26 let counter++ 27 continue 28 fi 29 fi 30 done 31 /etc/init.d/keepalived stop 32 exit 1
作者:木二
出处:http://www.cnblogs.com/itzgr/
关于作者:云计算、虚拟化,Linux,多多交流!
本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接!如有其他问题,可邮件(xhy@itzgr.com)咨询。