MySQL当前状态监控脚本

460阅读 0评论2016-04-11 xiaohaihai920
分类:Mysql/postgreSQL

该脚本可以监控当前MySQL的状态,可作为Keepalived高可用数据库来判断MySQL是否运行。

#!/bin/bash

/usr/local/mysql/bin/mysql -uroot -p123456 -e "show status" &>/dev/null
if [ $? -ne 0 ];then
    service keepalived stop
fi

chmod a+x /etc/keepalived/check_status_mysqld.sh

注:
假如mysqld is running, mysql -uroot -p123456 -e "show status" ,and echo $? = 0
假如mysqld is no running, mysql -uroot -p123456 -e "show status" ,and echo $? = 1
上一篇:MySQL 忘记密码:skip-grant-tables
下一篇:Oracle 笔记(四)