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
#!/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