Mysql 主从复制监控脚本

Mysql 主从复制监控脚本,
监控IO和SQL线程。如果问题。发送邮件报警。



#!/bin/bash
#write by lijun
#Date 2014-08-12
#Description monitor the master pass the data to the slave
#=====================
mail="邮件地址"

#===================

#获取slave io 进程和sql进程的状态

b="`mysql -uroot -p$a -e "show slave status\G;"|grep -E ‘Slave_IO_Running|Slave_SQL_Running‘|awk -F: ‘{print $2}‘|grep -v ‘^$‘`"

#判断两个进程是否开启

if [ b == "yes" ]
    then
        echo "IO thread and SQL thread are ‘yes‘"
    else
        yum install mail* -y  &>>/dev/null
        /etc/init.d/httpd restart
        echo
        echo "`date +%F-%T`主从复制错误,请进行检查."|mail -s "IO and SQL are wrong" $mail
        echo
     if [ $? -eq 0 ]
         then
             echo "send mail ok"
         else
             echo "send mail failed..."
             echo
     fi
fi

Mysql 主从复制监控脚本,布布扣,bubuko.com

Mysql 主从复制监控脚本

上一篇:SQLServer(MSSQL)、MySQL、SQLite、Access相互迁移转换工具 DB2DB v1.3


下一篇:Sql字符串拆分