Created
June 26, 2012 05:47
-
-
Save maimai-swap/2993575 to your computer and use it in GitHub Desktop.
KeepAlivedでHA構成したmysqlが落ちた時用のKeepAlivedとmysql.serverのシャットダウン用スクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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