检测MySQL主从是否异常

#!bin/bash
user='root'
passwd="123"
host="192.168.192.156"
mycmd="mysql -u$user -p$passwd -h $host"
chkdb(){
        list=($($mycmd -e "show slave status \G"|egrep "Running|Bebind"|awk -F: '{print $2}'))
        if [ ${list[0]} = "Yes" -a ${list[2]} = "Yes" -a ${list[2]} -lt 120 ];then
                echo "mysql slave is ok"
        else
                echo "mysql replation is filed!!"
        fi

}
chkdb

  

posted on 2019-09-29 15:58  快乐的人啊  阅读(244)  评论(0编辑  收藏  举报

导航