700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 自动监控主从MySQL同步的SHELL脚本

自动监控主从MySQL同步的SHELL脚本

时间:2019-11-14 13:27:46

相关推荐

自动监控主从MySQL同步的SHELL脚本

写了一个MySQL的主从复制的监控的脚本,欢迎一起讨论学习,qq1290518248

#!/bin/bash#check MySQL_Slave Status#crontab time 00:10MYSQLPORT=`netstat -na|grep "LISTEN"|grep "3306"|awk -F[:" "]+ '{print $4}'`MYSQLIP=`ifconfig eth0|grep "inet addr" | awk -F[:" "]+ '{print $4}'`STATUS=$(/usr/local/mysql/bin/mysql -u root -p000000 -S /tmp/mysql.sock -e "show slave status\G" | grep -i "running")IO_env=`echo $STATUS | grep IO | awk ' {print $2}'`SQL_env=`echo $STATUS | grep SQL | awk '{print $2}'`DATA=`date +"%y-%m-%d %H:%M:%S"`if [ "$MYSQLPORT" == "3306" ]thenecho "mysql is running"else/usr/local/bin/sendEmail -f ieee8023@ -t 1290517248@ -s -u "mysql is not running " -o message-content-type=html-o message-charset=utf8 -xu ieee8023@ -xp Syhy2yH -m "warn!server: $MYSQLIP mysql is down"fiif [ "$IO_env" = "Yes" -a "$SQL_env" = "Yes" ]thenecho "Slave is running!"elseecho "####### $DATA #########">> /data/data/check_mysql_slave.logecho "Slave is not running!" >> /data/data/check_mysql_slave.logecho "Slave is not running!" | /usr/local/bin/sendEmail -f ieee8023@ -t 1290517248@ -s -u "slave is not running!" -o message-content-type=html-o message-charset=utf8 -xu ieee8023@ -xp Syhy2yH -m "warn!server: $MYSQLIP mysql is down"fi

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。