Provision New SlaveΒΆ

Synopsis:

Provision a new slave from a backup of a master

Replicator:

Default Replicator

Applier:

Slave Applier

Version:

slave 1.1 (Drizzle 7.1)

Authors:

Marisa Plumb, Kent Bozlinski, Daniel Nichter

The basic formula for creating a new slave for an existing master is:

  1. Make a backup of the master databases.

  2. Record the max committed transaction ID of the master at the point the backup was made.

  3. Restore the backup on the new slave.

  4. Start the new slave from the recorded max committed transaction ID of the master.

Steps #1 and #2 are performed using the drizzledump Backup Tool and its --single-transaction option which prints a comment near the beginning of the dump output with the InnoDB transaction log metadata:

master$ drizzledump --all-databases --single-transaction > master-backup.sql

master$ grep SYS_REPLICATION_LOG master-backup.sql
-- SYS_REPLICATION_LOG: COMMIT_ID = 3303, ID = 3500

The SYS_REPLICATION_LOG comment provides the replication log metadata needed to start a new slave. There are two values:

COMMIT_ID

The commit sequence number recorded for the most recently executed transaction stored in the transaction log. This value is used to determine proper commit order within the log. ID, the unique transaction identifier, cannot be used because it is assigned when the transaction is started, not when it is committed.

ID

The unique transaction identifier associated with the most recently executed transaction stored in the transaction log.

For step #3, start the slave without the slave Plugin to prevent it from reading from the master until the backup is imported. Then import the backup on the slave:

slave$ drizzle < master-backup.sql

Stop the slave once the backup finishes importing.

For step #4, add the max-commit-id option to the Slave Config File:

# Example of existing lines
[master1]
master-host=10.0.0.1
master-user=slave
master-pass=foo

# Add this line
max-commit-id=3303

The value for max-commit-id is the COMMIT_ID value from the SYS_REPLICATION_LOG comment in the master dump file (steps #1 and #2). This value defines the committed transaction ID on the master from which the slave will start applying transactions.

Finally, start the slave with the slave Plugin and verify that replication is working (see Slave Administration).