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.

39 lines
951 B

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  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 "Stop local slave" > $log_file
  9. mysql --defaults-extra-file=./.my.cnf -e "STOP SLAVE;"
  10. #Started line on execute remote sql on remote server
  11. echo "Start execution all commands on remote server" >> $log_file
  12. REMOTE_SQL=
  13. for i in ${databases[@]}
  14. do
  15. REMOTE_SQL=$REMOTE_SQL' USE '$i'; FLUSH TABLES WITH READ LOCK;'
  16. done
  17. REMOTE_SQL=$REMOTE_SQL' system ./_activate-slave.sh; system ./_dump.sh;'
  18. for i in ${databases[@]}
  19. do
  20. REMOTE_SQL=$REMOTE_SQL' USE '$i'; UNLOCK TABLES;'
  21. done
  22. mysql --defaults-extra-file=./.remote.my.cnf -e "$REMOTE_SQL"
  23. echo "Start local slave" >> $log_file
  24. mysql --defaults-extra-file=./.my.cnf -e "START SLAVE;"
  25. if [[ "$1" = "master-to-master" ]]; then
  26. ./replication-master-to-master.sh;
  27. fi