#!/bin/bash
#
# To determine whether slave is running or not.
mysql_path=/usr/local/mysql/bin/mysql
user=root
password=123456
ip=$(/sbin/ifconfig | grep "inet addr" | grep -v "127.0.0.1" | awk '{print $2;}' | awk -F':' '{print $2;}' | head -1)
Slave_IO_Running=$($mysql_path -u$user -p$password -e 'show slave status\G' | grep "Slave_IO_Running" | awk '{print $2}')
Slave_SQL_Running=$($mysql_path -u$user -p$password -e 'show slave status\G' | grep "Slave_SQL_Running" | awk '{print $2}')
if [ "$Slave_IO_Running" = "Yes" -a "$Slave_SQL_Running" = "Yes" ]
then
echo "Slave is running!"
else
echo "Slave is not running!" > /var/log/mysql_slave.log
/bin/mail -s {$ip}_replicate_error 137xxxxxxx@139.com < /var/log/mysql_slave.log
fi
阅读(1297) | 评论(0) | 转发(0) |