标签:mysql主从状态检测
安装uuencode
yum install sharutils
创建shell脚本
#!/bin/bash date_str=`date +%Y%m%d` slave=$(/Disk/mysql/bin/mysql -ucheckslave -p123 -h 127.0.0.1 -e "show slave status\G" | grep Running | grep Yes | wc -l) if (( $slave == 2 )) then echo "Slave is OK | Status=${slave} Yes | date =${date_str}" >> /Disk/bak/local/mysql_slave_status.txt exit 0 else echo "Slave is Down | Status=${slave} Yes" | mail -s test3 test@kaiweijituan.com exit 2 fi
创建数据库的用户
GRANT REPLICATION CLIENT ON *.* TO checkslave@127.0.0.1 IDENTIFIED BY ‘nicaicai‘;
PS:
注意脚本中的命令和文件名字都要使用绝对路径
本文出自 “精忠报国” 博客,请务必保留此出处http://xinsir.blog.51cto.com/5038915/1567176
标签:mysql主从状态检测
原文地址:http://xinsir.blog.51cto.com/5038915/1567176