mirror of
https://github.com/bitnami/containers.git
synced 2026-03-21 15:29:05 +08:00
configure the MASTER_HOST before taking the dump
If you specify the `MASTER_HOST` or `MASTER_PORT` option, the slave assumes that the master server is different from before (even if the option value is the same as its current value.) In this case, the old values for the master binary log file name and position are considered no longer applicable, so if you do not specify `MASTER_LOG_FILE` and `MASTER_LOG_POS` in the statement, `MASTER_LOG_FILE=''` and `MASTER_LOG_POS=4` are silently appended to it. Do avoid the resetting of `MASTER_LOG_FILE` and `MASTER_LOG_POS`, we generated the dump after setting the `MASTER_HOST` https://dev.mysql.com/doc/refman/5.0/en/change-master-to.html
This commit is contained in:
@@ -76,12 +76,12 @@ configure_replication() {
|
||||
REPLICATION_USER=${REPLICATION_USER:-$MARIADB_MASTER_ENV_REPLICATION_USER}
|
||||
REPLICATION_PASSWORD=${REPLICATION_PASSWORD:-$MARIADB_MASTER_ENV_REPLICATION_PASSWORD}
|
||||
|
||||
echo "==> Setting the master configuration..."
|
||||
echo "CHANGE MASTER TO MASTER_HOST='$MASTER_HOST', MASTER_USER='$REPLICATION_USER', MASTER_PASSWORD='$REPLICATION_PASSWORD';" >> /tmp/init_mysql.sql
|
||||
|
||||
echo "==> Creating a data snapshot..."
|
||||
mysqldump -u$MASTER_USER ${MASTER_PASSWORD:+-p$MASTER_PASSWORD} -h $MASTER_HOST $MARIADB_DATABASE --master-data >> /tmp/init_mysql.sql
|
||||
|
||||
echo "==> Setting the master configuration..."
|
||||
echo "CHANGE MASTER TO MASTER_HOST='$MASTER_HOST', MASTER_USER='$REPLICATION_USER', MASTER_PASSWORD='$REPLICATION_PASSWORD'" >> /tmp/init_mysql.sql
|
||||
|
||||
echo "==> Starting the slave..."
|
||||
echo "START SLAVE ;" >> /tmp/init_mysql.sql
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user