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/

posted @ 2021-04-26 17:42  赵海博运维笔记  阅读(260)  评论(0编辑  收藏  举报