1. 程式人生 > >008.MySQL-Keepalived搭配指令碼02

008.MySQL-Keepalived搭配指令碼02

  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通知
" [email protected] 8 } 9 echo "$isok" 10 if [ "$isok" != "1" ] 11 then 12 #echo 'diaoyong error' 13 error_query 14 fi