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.

41 lines
977 B

4 years ago
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;'
  18. REMOTE_SQL=$REMOTE_SQL' system ./_dump.sh;'
  19. for i in ${databases[@]}
  20. do
  21. REMOTE_SQL=$REMOTE_SQL' USE '$i'; UNLOCK TABLES;'
  22. done
  23. mysql --defaults-extra-file=./.remote.my.cnf -e "$REMOTE_SQL"
  24. echo "Start local slave" >> $log_file
  25. mysql --defaults-extra-file=./.my.cnf -e "START SLAVE;"
  26. if [[ "$1" = "master-to-master" ]]; then
  27. ./replication-master-to-master.sh;
  28. fi