分类: LINUX
2010-03-09 16:13:59
socket=/var/lib/mysql/mysql.sock
user=root
for i in $socket
do
mysql=$(mysql -u $user --socket=$i -e "show slave status\G" | \
awk 'BEGIN {
tel = 0
}
/Slave_IO_Running: Yes/ { tel++ }
/Slave_SQL_Running: Yes/ { tel++ }
END {
if ( tel == 2 ) {
print "Yes"
} else {
print "No"
}
}'
)
if [ $mysql = Yes ]; then
echo "mysql主从正常"
else
echo "mysql主从出现故障"
fi
done