標籤:exit relay second read 延時 cond word usr master
#!/bin/bashUSER="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 exitfiif [[ ${status[4]} > '300' ]]; then #echo "the lag is too long, at $(date)" > monitor_err.log echo 2 exitfiif [[ ${status[0]} == ${status[2]} ]] && [[ ${status[1]} == ${status[3]} ]]; then #echo "the replication is normal" echo 0 exitelse #echo "the replication is fault,at $(date)" > monitor_err.log echo 3 exitfi
MySQL 主從複製延時監控