mysql集群监控check_mysql_slave_run.sh
sh_path=$(cd $(dirname $0);pwd)
cd ${sh_path}
port1="3306"
param1="mysql服务"
echo `date "+%Y-%m-%d %H:%M:%S"`
sh check_mysql_login.sh xx.xx.xx.xx ${port1} ${param1}
sh check_mysql_slave.sh xx.xx.xx.xx ${port1} ${param2}
echo `date "+%Y-%m-%d %H:%M:%S"`
mysql服务连接状态监控check_mysql_login.sh
source ~/.bash_profile
file_msg=""
if [ $2 == 3306 ]
if [ `mysql ${dw5_3306} -ucmbh -h$1 -P$2 -e "show slave statusG;"|grep "Master_User:"|grep -c "cmbh"` != "1" ] ;then
file_msg=$3$1"mysql连接异常"
fi
![](https://img2020.cnblogs.com/blog/2069550/202103/2069550-20210330150116840-1917728979.png)
##mysql主从连接状态监控check_mysql_slave.sh
source ~/.bash_profile
file_msg=""
if [ `mysql ${dw5_3306} -ucmbh -h$1 -P$2 -e "show slave statusG;"|grep -E "Slave_IO_Running:|Slave_SQL_Running:"|grep -c "Yes"` != "2" ] ;then
file_msg="IP:_$1:$2;Mysql主从同步异常_时间:_`date +%Y-%m-%d_%H:%M:%S`"
fi