首页 > 数据库技术 > 详细

MySQL 主从复制延时监控

时间:2018-07-24 10:13:56      阅读:204      评论:0      收藏:0      [点我收藏+]
#!/bin/bash USER="root" PASSWORD="root" MYSQL="/usr/mysql/mysql-5.6.10/client/mysql" HOST="10.198.18.18" thread_status=$($MYSQL -u"$USER" -p"$PASSWORD" -h"$HOST" -e 'show slave status\G' | grep -i yes | wc -l) status=($($MYSQL -u"$USER" -p"$PASSWORD" -h"$HOST" -e 'show slave status\G' | egrep -i "Master_Log_File|Relay_Master_Log_File|Read_Master_Log_Pos|Exec_Master_Log_Pos|Seconds_Behind_Master" | awk -F':' '{print $2}')) if [[ $thread_status != 2 ]]; then          #echo "the replication is fault, at $(date)" > monitor_err.log          echo 1          exit fi if [[ ${status[4]} > '300' ]]; then          #echo "the lag is too long, at $(date)" > monitor_err.log          echo 2          exit fi if [[ ${status[0]} == ${status[2]} ]] && [[ ${status[1]} == ${status[3]} ]]; then          #echo "the replication is normal"          echo 0          exit else          #echo "the replication is fault,at $(date)" > monitor_err.log          echo 3          exit fi


MySQL 主从复制延时监控

原文:http://blog.51cto.com/ultrasql/2149249

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!