008.MySQL-Keepalived搭配脚本02

2019-07-26 16:34:47 浏览数 (1)

代码语言:javascript复制
  1 vim /etc/keepalived/check_MySQL.sh
  2 #!/bin/sh
  3 #isok=$(sed -n '2p' /etc/keepalived/result.txt)
  4 isok=$(/usr/local/mysql/bin/mysql -uroot -p123456 -e 'select 1' |sed -n '2p')
  5 function error_query(){
  6 	service keepalived  stop
  7 	echo "172.16.16.34  mysql  down, keepalived 切换" | mail -s "34MySQL keepalived通知" ma.xiangqian@sf-express.com
  8 }
  9 echo "$isok"
 10 if [ "$isok" != "1" ]
 11 then
 12 	#echo 'diaoyong error'
 13 	error_query
 14 fi

0 人点赞