检测MySQL主从备份是否运行

通过查看 slave  状态,确保 Slave_IO_Running: Yes Slave_SQL_Running:
Yes

#!/bin/bash
#Author:Darius-D
mysql -uroot -p123123 -e ‘show slave statusG’ >a.txt
IO=`head -12 a.txt | tail -1|awk -F ‘:’ ‘{print $2}’`
SQL=`head -13 a.txt | tail -1|awk -F ‘:’ ‘{print $2}’`
if [ $IO == ‘Yes’ ];then
echo “Slave_IO_Running:Yes”
if [ $SQL == ‘Yes’ ];then
echo “Slave_SQL_Running:Yes”
else
echo “Slave_SQL_Running:No”
fi
else
echo “Slave_IO_Running:No”
fi
有关于mysql主从备份相关原理及备份链接进入查看。