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.

25 lines
1.1 KiB

5 years ago
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. # Установка локально и удаленно MASTER-параметров
  9. echo "Get master status from remote server" >> $log_file
  10. remote_master_status=`mysql --defaults-extra-file=./.remote.my.cnf -e "SHOW MASTER STATUS;
  11. " -N`
  12. remote_master_log_file=`echo $remote_master_status | cut -d' ' -f1`
  13. remote_master_log_pos=`echo $remote_master_status | cut -d' ' -f2`
  14. echo "Apply bin log position to local mariadb db instance" >> $log_file
  15. replication_user=`cat ./.remote.my.cnf | grep user | cut -d'=' -f2`
  16. replication_password=`cat ./.remote.my.cnf | grep password | cut -d'=' -f2`
  17. replication_host=`cat ./.remote.my.cnf | grep host | cut -d'=' -f2`
  18. mysql --defaults-extra-file=./.my.cnf -e "CHANGE MASTER TO MASTER_HOST = '$replication_hos
  19. t', MASTER_USER = '$replication_user', MASTER_PASSWORD = '$replication_password', MASTER_L
  20. OG_FILE = '$remote_master_log_file', MASTER_LOG_POS = $remote_master_log_pos;"