监控mysql跟heartbeat的脚本
#!/bin/sh cat/var/log/mysql_ha.logmail -s "mysql and ha warning!server: $DB1IP ha is down" hamgua@gmail.com < /var/log/mysql_ha.log
fi
fi
else
if [ "$HAPORT" == "694" ];then
echo "$DB1IP mysql is down,but ha is runing,now shutdown ha,let (DB2IP) to take over mysql,then restart mysql....." > /var/log/mysql_ha.log
mail -s "mysql and ha warning!server: $DB1IP mysql is down" hamgua@gmail.com < /var/log/mysql_ha.log
/etc/rc.d/init.d/heartbeat stop
/etc/rc.d/init.d/mysqld start
if [ "$MYPORT" == "3306"];then
/etc/rc.d/init.d/heartbeat start
echo "$DB1IP$mysql restart successful,now mysql and ha all running......"
fi
else
echo "$DB1IPmysql and ha all down,first restart msyql,when mysql is run,restart ha"
/etc/rc.d/init.d/mysqld start
if [ "$MYPORT" == "3306"];then
/etc/rc.d/init.d/heartbeat start
if [ "$HAPORT" == "694" ];then
echo "$DB1IPmysql and ha all running......"
else
echo "$DB1IPmysql is running,ha is down,please restart ha" > /var/log/mysql_ha.log
mail -s "mysql and ha warning!server: $DB1IP ha is down" hamgua@gmail.com < /var/log/mysql_ha.log
fi
else
echo "$DB1IPmysql and ha all down,let (DB2IP) to take over mysql,please restart mysql" > /var/log/mysql_ha.log
mail -s "mysql and ha warning!server: $DB1IP mysql and ha all down" hamgua@gmail.com < /var/log/mysql_ha.log
fi
fi
fi
sleep 10
done
页:
[1]