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:
Sameer Naik
2015-07-28 20:20:26 +05:30
parent 993b16471e
commit 4cf7c4702b

View File

@@ -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
;;