#!/bin/bash
# author:wdlinux
# url:http://www.wdlinux.cn
# description:monitor shell of mysql
local_ip=192.168.1.92
rip=192.168.1.91
mysql_in=/usr/local/mysqlm
mysql_bin=${mysql_in}/bin/mysql
mysql_user=root
mysql_pass=12345
mysql_port=3306
st=0
while true;do
if (${mysql_bin} -h"${rip}" -u"${mysql_user}" -p"${mysql_pass}" -P"${mysql_port}" -e "show master status" --connect_timeout=1 > /
dev/null 2>&1)
then
if (($st==0));then
/etc/rc.d/init.d/mysql_start1.sh stop
let st=$st+1
fi
else
for ((i=0;i<=3;i++));do
sleep 3
if (${mysql_bin} -h"${rip}" -u"${mysql_user}" -p"${mysql_pass}" -P"${mysql_port}" -e "show master status" --conne
ct_timeout=1 > /dev/null 2>&1)
then
break
else
if (($i==3));then
echo "slave to master"
/etc/rc.d/init.d/mysql_start1.sh start
###modify dns prg
exit
fi
fi
done
fi
sleep 3
done