欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

检测MySQL主从备份是否运行

程序员文章站 2022-06-10 13:05:39
通过查看 slave 状态,确保 Slave_IO_Running: Yes Slave_SQL_Running: Yes #!/bin/bash#Author:Darius-Dmysql -uroot -p123123 -e 'show slave status\G' >a.txtIO=`head ......

通过查看 slave  状态,确保 slave_io_running: yes slave_sql_running: yes

#!/bin/bash
#author:darius-d
mysql -uroot -p123123 -e 'show slave status\g' >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主从备份相关原理及备份链接进入查看。

https://www.cnblogs.com/darius-d/p/9522619.html