* config example rename
+ master-to-master replication functionality
This commit is contained in:
23
_activate-slave.sh
Executable file
23
_activate-slave.sh
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
CONFIG_FILE=$DIR/_config.sh
|
||||
[[ ! -r "${CONFIG_FILE}" ]] && { echo "Could not read ${CONFIG_FILE}!"; exit 1; }
|
||||
set -a
|
||||
. "${CONFIG_FILE}"
|
||||
set +a
|
||||
|
||||
# Установка локально и удаленно MASTER-параметров
|
||||
echo "Get master status from remote server" >> $log_file
|
||||
remote_master_status=`mysql --defaults-extra-file=./.remote.my.cnf -e "SHOW MASTER STATUS;
|
||||
" -N`
|
||||
|
||||
remote_master_log_file=`echo $remote_master_status | cut -d' ' -f1`
|
||||
remote_master_log_pos=`echo $remote_master_status | cut -d' ' -f2`
|
||||
|
||||
echo "Apply bin log position to local mariadb db instance" >> $log_file
|
||||
|
||||
replication_user=`cat ./.my.cnf | grep user | cut -d'=' -f2`
|
||||
replication_password=`cat ./.my.cnf | grep password | cut -d'=' -f2`
|
||||
replication_host=`cat ./.my.cnf | grep host | cut -d'=' -f2`
|
||||
|
||||
mysql --defaults-extra-file=./.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;"
|
||||
Reference in New Issue
Block a user