Commit 6b2b5800 authored by Vincent Pelletier's avatar Vincent Pelletier

stack/erp5: Improve clone startup script.

Always running SQL_CHANGE_MASTER breaks GTID setup (at least on 10.1.24)
as it resets MASTER_USE_GTID. So only run it when not using GTID.
Also, fold SQL_SET_GTID into the existing "if" bloc for simplicity.
parent 0d302559
...@@ -22,7 +22,7 @@ md5sum = 0c0d98a68230cd0ad36046bb25b35f4a ...@@ -22,7 +22,7 @@ md5sum = 0c0d98a68230cd0ad36046bb25b35f4a
[mariadb-start-clone-from-backup] [mariadb-start-clone-from-backup]
filename = instance-mariadb-start-clone-from-backup.sh.in filename = instance-mariadb-start-clone-from-backup.sh.in
md5sum = 1af531c51f575a1d1362f2ca2d61620d md5sum = e405227118a70fbf949a6414469989db
[template-mariadb] [template-mariadb]
filename = instance-mariadb.cfg.in filename = instance-mariadb.cfg.in
......
...@@ -88,6 +88,7 @@ zcat "$BACKUP" | "$CLIENT" -u root ...@@ -88,6 +88,7 @@ zcat "$BACKUP" | "$CLIENT" -u root
echo "Configuring server as slave..." echo "Configuring server as slave..."
if [ "$MASTER_USE_GTID" -eq 1 ]; then if [ "$MASTER_USE_GTID" -eq 1 ]; then
"$CLIENT" -u root -e "$SQL_SET_GTID"
MASTER_USE_GTID_SQL="current_pos" MASTER_USE_GTID_SQL="current_pos"
else else
MASTER_USE_GTID_SQL="NO" MASTER_USE_GTID_SQL="NO"
...@@ -104,8 +105,14 @@ fi ...@@ -104,8 +105,14 @@ fi
MASTER_SSL_VERIFY_SERVER_CERT=1, MASTER_SSL_VERIFY_SERVER_CERT=1,
MASTER_USE_GTID=$MASTER_USE_GTID_SQL; MASTER_USE_GTID=$MASTER_USE_GTID_SQL;
" "
"$CLIENT" -u root -e "$SQL_CHANGE_MASTER" if [ "$MASTER_USE_GTID" -eq 0 ]; then
test "$MASTER_USE_GTID" -eq 1 && "$CLIENT" -u root -e "$SQL_SET_GTID" # No GTID, use binlog name & offset as provided by backup file.
# Example: CHANGE MASTER TO MASTER_LOG_FILE='binlog.003447', MASTER_LOG_POS=360;
# Notes:
# - Must happen after setting MASTER_HOST & MASTER_PORT.
# - Implicitly sets MASTER_USE_GTID=NO if it was set before.
"$CLIENT" -u root -e "$SQL_CHANGE_MASTER"
fi
"$CLIENT" -u root -e "START SLAVE;" "$CLIENT" -u root -e "START SLAVE;"
echo "Stopping mariadb..." echo "Stopping mariadb..."
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment