检测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