MYSQL Slave开机启动和检查脚本
#!/bin/sh
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
转载于:http://blog.itpub.net/10569970/viewspace-1800386/