export PATH=/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
user=root
password=root
mysql -u$user -p$password -e "show slave status\G;"|grep -i running > slavestatus.log
if [ `cat slavestatus.log | grep -i IO | awk '{print $2}'` = Yes ];
then
echo "slave Io process is OK"
else
mysql -u$user -p$password -e "stop slave;"
wait;
mysql -u$user -p$password -e "start slave;"
wait;
echo "`date` IO slave has started" >> slavemon.log
fi
if [ `cat slavestatus.log | grep -i SQL | awk '{print $2}'` = Yes ];
then
echo "slave SQL process is OK"
else
mysql -u$user -p$password -e "stop slave;"
wait;
mysql -u$user -p$password -e "start slave;"
wait;
echo "`date` SQL slave has started" >> slavemon.log
fi
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10569970/viewspace-1800386/,如需转载,请注明出处,否则将追究法律责任。