shell 判断主从状态

#!/bin/bash
a=$(mysql -e "show slave status\G" | awk '/Slave_IO_Running/ {print $2}')
b=$(mysql -e "show slave status\G" | awk '/Slave_SQL_Running/ {print $2}')

if [ $a == 'Yes' -a $a == $b ]; then
echo "yes"
else
echo "no"
fi

posted @ 2020-05-21 20:40  fang12311  阅读(7)  评论(0编辑  收藏  举报