MySQL主从复制从库状态监测

Posted seasonzone

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL主从复制从库状态监测相关的知识,希望对你有一定的参考价值。

mysqlPORT=`netstat -na|grep "LISTEN"|grep "3306"|awk -F[:" "]+ ‘{print $5}‘`  
MYSQLIP=`ifconfig eth0|grep "inet addr" | awk -F[:" "]+ ‘{print $4}‘`  
STATUS=$(/usr/local/mysql/bin/mysql -uroot -pqkjr_420 -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"`  

function checkMysqlStatus(){  
    if [ "$MYSQLPORT" == "3306" ]  
    then  
        /usr/local/mysql/bin -uroot -pqkjr_420 --connect_timeout=5 -e "show databases;" &>/dev/null 2>&1  
        if [ $? -ne 0 ]  
        then  
            echo "Server: $MYSQLIP mysql is down, please try to restart mysql by manual!" > /var/log/mysqld.log
            mail -s "WARN! server: $MYSQLIP  mysql is down." [email protected] < /var/log/mysqld.log
        else  
            echo "mysql is running..."  
        fi  
    else  
        mail -s "WARN!Server: $MYSQLIP mysql is down." [email protected]  
    fi  
}  

checkMysqlStatus  

if [ "$IO_env" = "Yes" -a "$SQL_env" = "Yes" ]  
then  
  echo "MySQL Slave is running!"  
else  
  echo "####### $DATA #########">> /usr/local/mysql/mysql_slave_status.log  
  echo "MySQL Slave is not running!" >>    /usr/local/mysql/mysql_slave_status.log  
  echo "MySQL Slave is not running!" | mail -s "WARN! $MYSQLIP MySQL Slave is not running." [email protected] 
fi

http://blog.csdn.net/qq_25067905/article/details/70207740

以上是关于MySQL主从复制从库状态监测的主要内容,如果未能解决你的问题,请参考以下文章

PHP 简介

全角半角字符对照表

深度学习-机器视觉学习路线

HTML常用标签

关于HTML5代码总结。

对称加密算法和非对称加密算法