检查Mysql主从状态

.检查MySQL主从同步状态

 

#!/bin/bash  

USER=bak

PASSWD=123456

IO_SQL_STATUS=$(mysql -u$USER -p$PASSWD -e  show slave statusG  |awk -F:  /Slave_.*_Running/{gsub(": ",":");print $0} )  #gsub去除冒号后面的空格

for i in $IO_SQL_STATUS; do

    THREAD_STATUS_NAME=${i%:*}

    THREAD_STATUS=${i#*:}

    if [ "$THREAD_STATUS" != "Yes" ]; then

        echo "Error: MySQL Master-Slave $THREAD_STATUS_NAME status is $THREAD_STATUS!"

    fi

done

posted @ 2019-07-12 13:54  #赵程#  阅读(1525)  评论(0编辑  收藏  举报