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.

27 lines
688 B

5 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. for i in ${databases[@]}
  9. do
  10. REMOTE_SQL=$REMOTE_SQL' USE '$i'; FLUSH TABLES WITH READ LOCK;'
  11. done
  12. REMOTE_SQL=$REMOTE_SQL' system ./readbinlog.sh;'
  13. REMOTE_SQL=$REMOTE_SQL' system ./dump.sh;'
  14. for i in ${databases[@]}
  15. do
  16. REMOTE_SQL=$REMOTE_SQL' USE '$i'; UNLOCK TABLES;'
  17. done
  18. echo "Start execution all commands on remote server" > $log_file
  19. mysql --defaults-extra-file=./.remote.my.cnf -e "$REMOTE_SQL"
  20. mysql --defaults-extra-file=./.my.cnf -e "START SLAVE;"