You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
913 B

  1. #!/bin/bash
  2. export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  3. CONFIG_FILE=$DIR/config.sh
  4. [[ ! -r "${CONFIG_FILE}" ]] && { echo "Could not read ${CONFIG_FILE}!"; exit 1; }
  5. set -a
  6. . "${CONFIG_FILE}"
  7. set +a
  8. echo "Started activation of master-to-master replication" >> $log_file
  9. echo "Stop remote slave" >> $log_file
  10. mysql --defaults-extra-file=./.remote.my.cnf -e "STOP SLAVE;"
  11. echo "Execute command on local server with push local binlog position to remote server" >> $log_file
  12. LOCAL_SQL=
  13. for i in ${databases[@]}
  14. do
  15. LOCAL_SQL=LOCAL_SQL' USE '$i'; FLUSH TABLES WITH READ LOCK;'
  16. done
  17. LOCAL_SQL=LOCAL_SQL' system ./_activate-master-to-master.sh;'
  18. for i in ${databases[@]}
  19. do
  20. LOCAL_SQL=LOCAL_SQL' USE '$i'; UNLOCK TABLES;'
  21. done
  22. mysql --defaults-extra-file=./.my.cnf -e "$REMOTE_SQL"
  23. echo "Start remote slave" >> $log_file
  24. mysql --defaults-extra-file=./.remote.my.cnf -e "START SLAVE;"