+ additional logger comments
* really execute master-to-master replication commands
This commit is contained in:
@ -6,6 +6,12 @@ set -a
|
|||||||
. "${CONFIG_FILE}"
|
. "${CONFIG_FILE}"
|
||||||
set +a
|
set +a
|
||||||
|
|
||||||
|
echo "Stop local slave" > $log_file
|
||||||
|
mysql --defaults-extra-file=./.my.cnf -e "STOP SLAVE;"
|
||||||
|
|
||||||
|
#Started line on execute remote sql on remote server
|
||||||
|
echo "Start execution all commands on remote server" >> $log_file
|
||||||
|
|
||||||
REMOTE_SQL=
|
REMOTE_SQL=
|
||||||
|
|
||||||
for i in ${databases[@]}
|
for i in ${databases[@]}
|
||||||
@ -22,13 +28,20 @@ do
|
|||||||
REMOTE_SQL=$REMOTE_SQL' USE '$i'; UNLOCK TABLES;'
|
REMOTE_SQL=$REMOTE_SQL' USE '$i'; UNLOCK TABLES;'
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Start execution all commands on remote server" > $log_file
|
|
||||||
|
|
||||||
mysql --defaults-extra-file=./.remote.my.cnf -e "$REMOTE_SQL"
|
mysql --defaults-extra-file=./.remote.my.cnf -e "$REMOTE_SQL"
|
||||||
|
|
||||||
|
echo "Start local slave" >> $log_file
|
||||||
|
|
||||||
mysql --defaults-extra-file=./.my.cnf -e "START SLAVE;"
|
mysql --defaults-extra-file=./.my.cnf -e "START SLAVE;"
|
||||||
|
|
||||||
if [[ "$1" = "master-to-master" ]]; then
|
if [[ "$1" = "master-to-master" ]]; then
|
||||||
|
echo "Started activation of master-to-master replication" >> $log_file
|
||||||
|
|
||||||
|
echo "Stop remote slave" >> $log_file
|
||||||
|
mysql --defaults-extra-file=./.remote.my.cnf -e "STOP SLAVE;"
|
||||||
|
|
||||||
|
echo "Execute command on local server with push local binlog position to remote server" >> $log_file
|
||||||
|
|
||||||
LOCAL_SQL=
|
LOCAL_SQL=
|
||||||
|
|
||||||
for i in ${databases[@]}
|
for i in ${databases[@]}
|
||||||
@ -42,6 +55,12 @@ if [[ "$1" = "master-to-master" ]]; then
|
|||||||
do
|
do
|
||||||
LOCAL_SQL=LOCAL_SQL' USE '$i'; UNLOCK TABLES;'
|
LOCAL_SQL=LOCAL_SQL' USE '$i'; UNLOCK TABLES;'
|
||||||
done
|
done
|
||||||
|
|
||||||
|
mysql --defaults-extra-file=./.my.cnf -e "$REMOTE_SQL"
|
||||||
|
|
||||||
|
echo "Start remote slave" >> $log_file
|
||||||
|
|
||||||
|
mysql --defaults-extra-file=./.remote.my.cnf -e "START SLAVE;"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user