安装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 [email protected] exit 2 fi
创建数据库的用户
GRANT REPLICATION CLIENT ON *.* TO [email protected] IDENTIFIED BY ‘nicaicai‘;
PS:
注意脚本中的命令和文件名字都要使用绝对路径
时间: 2024-10-08 05:06:50