虚拟化容器,大数据,DBA,中间件,监控。

MySQL 主从监控脚本

21 12月
作者:admin|分类:DBA运维
[root@localhost ~]# cat check_mysql_slave.sh 
#!/bin/bash
#chek mysql master slave status script

mysql_port=$(netstat -na | grep -w "LISTEN" | grep "3306" | awk '{print $4}' | awk -F[.:] '{print $5}')
mysql_ip=$(ip a | grep "ens33" | grep "inet" | awk '{print $2}')
io_env=$(/usr/local/mysql55/bin/mysql -e "show slave status\G" | grep -i "running" | grep IO | awk '{print $2}')
sql_env=$(/usr/local/mysql55/bin/mysql -e "show slave status\G" | grep -i "running" | grep SQL | awk '{print $2}')


if [ "$mysql_port" == "3306" ];then
	echo "mysql is running"
else
      mail -s "warn!server: $mysql_ip mysql is down"  xxx@mail.com
fi

if [ "$io_env" == "Yes" -a "$sql_env" == "Yes" ];then
	echo "Slave is running"
else
	 mail -s "Warning! $mysql_ip replication error" xxx@mail.com
fi

 

浏览523 评论0
返回
目录
返回
首页
CentOS 7下Docker桥接网络,实现独立IP与独立端口效果 MySQL 主主复制