Chinaunix首页 | 论坛 | 博客
  • 博客访问: 457417
  • 博文数量: 145
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1139
  • 用 户 组: 普通用户
  • 注册时间: 2014-01-14 16:47
个人简介

路漫漫其修远兮,吾将上下而求索

文章分类

全部博文(145)

文章存档

2016年(10)

2015年(15)

2014年(120)

我的朋友

分类: LINUX

2014-01-15 15:24:45


点击(此处)折叠或打开

  1. #!/bin/bash
  2. #set -x
  3. #grant all privileges on *.* to 'repair'@'%' identified by 'repair';
  4. #When found synchronous appear unable to synchronization time "will be automatically extracted the main library file number, and pos, synchronous primary library。
  5. mstool="/usr/local/mysql/bin/mysql -h 192.168.11.128 -urepair -prepair -P 3306"
  6. sltool="/usr/local/mysql/bin/mysql -h 192.168.11.129 -urepair -prepair -P 3306"
  7. declare -a slave_stat
  8. slave_stat=($($sltool -e "show slave status\G"|grep Running |awk '{print $2}'))
  9. if [ "${slave_stat[0]}" = "Yes" -a "${slave_stat[1]}" = "Yes" ]
  10. then
  11. echo "OK slave is running"
  12. exit 0
  13. else
  14. echo "Critical slave is error"
  15. echo
  16. echo "*********************************************************"
  17. echo "Now Starting replication with Master Mysql!"
  18. file=`$mstool -e "show master status\G"|grep "File"|awk '{print $2}'`
  19. pos=`$mstool -e "show master status\G"|grep "Pos"|awk '{print $2}'`
  20. $sltool -e "slave stop;change master to master_host='192.168.11.128',master_port=3306,master_user='replication',master_password='slave',master_log_file='$file',master_log_pos=$pos;slave start;"
  21. sleep 3
  22. $sltool -e "show slave status\G;"|grep Running
  23. echo
  24. echo "Now Replication is Finished!"
  25. echo
  26. echo "**********************************************************"
  27. exit 2
  28. fi

阅读(691) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~