作用:关闭从myql的slave,启动mysql的slave,查看mysql slave状态
- #!/bin/bash
-
mysqldir=/usr/local/mysql/bin
-
M_HOST='172.20.25.11'
-
USER='rdbrep'
-
paswd='rdbrep_yy'
-
-
#define start function
-
start(){
-
echo "Starting slave ...."
-
$mysqldir/mysql -u$USER -p$paswd -e 'slave start;'
-
NUM=`$mysqldir/mysql -u$USER -p$paswd -e "show slave status\G"|grep -ie "running"|grep 'Yes' |wc -l`
-
if [ $NUM -eq 2 ];then
-
echo "slave start sucessfull ...."
-
-
else
-
echo "slave start fail ...."
-
-
-
fi
-
}
-
-
-
# define stop function
-
stop(){
-
echo "stoppint slavle ...."
-
$mysqldir/mysql -u$USER -p$paswd -e 'slave stop;'
-
NUM=`$mysqldir/mysql -u$USER -p$paswd -e "show slave status\G"|grep -ie "running"|grep 'NO' |wc -l`
-
-
if [ $NUM -eq 2 ];then
-
echo "slave stop sucessfull ...."
-
else
-
echo "salve stop fail ...."
-
-
fi
-
}
-
-
#define status function
-
status(){
-
$mysqldir/mysql -u$USER -p$paswd -e "show slave status\G"|grep -ie "running"
-
-
}
-
-
-
-
#See how we are called
-
case "$1" in
-
start)
-
start
-
;;
-
stop)
-
stop
-
;;
-
status)
-
status
-
;;
-
*)
-
echo $"Usage: /bin/sh slave.sh {start|stop|status}"
-
exit 1
-
esac
阅读(2481) | 评论(0) | 转发(0) |