检查mysql主从同步结构中的从数据库服务器的状态-脚本shell
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了检查mysql主从同步结构中的从数据库服务器的状态-脚本shell相关的知识,希望对你有一定的参考价值。
检查mysql主从同步结构(一主一从)中的从数据库服务器的状态
(ip授权、从服务器和IO是否正常、从mysql进程是否正常)
主mysql: 192.168.1.10
从mysql: 192.168.1.20
[[email protected] ~]# vi check_slave.sh
#!/bin/bash
master=192.168.1.10
i=1
service mysqld status &>/dev/null
while [ true ]
do
echo $i
service mysqld status &>/dev/null
if[ $? -ne 0 ];then
echo "slave server is down!"
exit
fi
ping -c 3 $master &>/dev/null
if[ $? -ne 0 ];then
echo "physical link is disconnected!"
exit
else
grant=`mysql -h$master -uslave -ptarena -Bse ‘show grants [email protected]‘`
grant_1="GRANT REPLICATION SLAVE ON *.* TO ‘slave‘@‘192.168.1.20‘IDENTIFIED BY PASSWORD ‘3907ff810e745021‘"
if [ "$grant" !="$grant_1" ];then
echo "There is no grant for slave server!"
exit
fi
stat_1=`mysql -Bse ‘show slave status\G‘ | grep Slave_IO_Running | awk -F ":" ‘{ print $2}‘`
stat_2=`mysql -Bse ‘show slave status\G‘ | grep Slave_SQL_Running | awk -F ":" ‘{ print $2}‘`
if [ $stat_1 != "Yes" ];then
echo "IO progress has something wrong!"
exit
fi
if [ $stat_2 != "Yes" ];then
echo "SQL progress has something wrong !"
exit
fi
leti++
done
本文出自 “Dave-技术博客” 博客,请务必保留此出处http://davewang.blog.51cto.com/6974997/1855106
以上是关于检查mysql主从同步结构中的从数据库服务器的状态-脚本shell的主要内容,如果未能解决你的问题,请参考以下文章