A Monitor For MySQL Replication

2009-05-26  |  15:54分类:MySQL  |  1,870 views

该脚本通过监视Slave上的IO_ThreadSQL_Thread的运行情况,来判断Relication运行是否正常;在下面的代码上,填上你的数据库用户名、密码并且在“DO SOMETHING….”加上你自己的报警代码就可以了。该脚本在patchLog上的一个脚本上修改得到。

zzx@oiegg:~$ vi replicationMonitor.sh
#!/bin/sh
# replicationMonitor.sh – a mysql replication monitor
dbuser = “”
dbpwd = “”
rf=$(mktemp)
echo “SHOW SLAVE STATUS\G”|\
mysql -u $dbuser -p$dbpwd > $rf 2>&1

repl_IO=$(cat $rf|grep “Slave_IO_Running”|cut -f2 -d’:')
repl_SQL=$(cat $rf|grep “Slave_SQL_Running”|cut -f2 -d’:')
if [ "$repl_IO" != " Yes" -o "$repl_SQL" != " Yes" ] ; then
DO SOMETHING….
fi
rm $rf 

–EOF–

喜欢本文,那就收藏到: Del.icio.us Google书签 Digg Live Bookmark Yahoo书签 Facebook 百度搜藏 添加到饭否 QQ书签 Digbuzz我挖网
  • No Related Post

发表您的评论