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.

23 lines
1.1 KiB

  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 local server" >> $log_file
  10. local_master_status=`mysql --defaults-extra-file=./.my.cnf -e "SHOW MASTER STATUS;
  11. " -N`
  12. local_master_log_file=`echo $local_master_status | cut -d' ' -f1`
  13. local_master_log_pos=`echo $local_master_status | cut -d' ' -f2`
  14. echo "Apply bin log position to remote mariadb db instance" >> $log_file
  15. replication_user=`cat ./.my.cnf | grep user | cut -d'=' -f2`
  16. replication_password=`cat ./.my.cnf | grep password | cut -d'=' -f2`
  17. replication_host=$localdatabasepublicip
  18. mysql --defaults-extra-file=./.remote.my.cnf -e "CHANGE MASTER TO MASTER_HOST = '$replication_host', MASTER_USER = '$replication_user', MASTER_PASSWORD = '$replication_password', MASTER_LOG_FILE = '$remote_master_log_file', MASTER_LOG_POS = $remote_master_log_pos;"