Skip to content

Instantly share code, notes, and snippets.

@maimai-swap
Created June 26, 2012 05:47
Show Gist options
  • Save maimai-swap/2993575 to your computer and use it in GitHub Desktop.
Save maimai-swap/2993575 to your computer and use it in GitHub Desktop.
KeepAlivedでHA構成したmysqlが落ちた時用のKeepAlivedとmysql.serverのシャットダウン用スクリプト
#!/bin/bash
####
#もしマスタが落ちたときの処理スクリプト
#とりあえず最終確認して、本当にダメだったらkeepalivedを落とす。
####
#ちょっと待つ
sleep 5
#本当にmysqlが死んでいるかどうかの確認
mysqlans=`mysql -u tbacojx -pdasuinzc -h 127.0.0.1 --port=3306 < /usr/local/keepscript/s
howmaster.sql | grep Bytes_received | awk '{print $1}'`
#もし、本当に死んでいるときは、keepalivedを落とす。
if [ "Bytes_received" = "$mysqlans" ]; then
echo "MYSQL ALIVE..."
else
echo "MYSQL DOWN..."
/sbin/service mysqld stop
/sbin/service keepalived stop
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment