I'm using a standard MySQL replica setup with a single master and a single replica. Now I want to create a new replica so that I have one master and two replicas. To setup the new replica, I wanted to do a MySQL dump of the existing replica instead of doing this from the master.
When doing this, I think I first need to stop the replica to get a consistent dataset:
mysql> STOP SLAVE;
Then I would find the replication coordinates so I can start my new replica at the correct replication point:
mysql> SHOW SLAVE STATUS\G
Then I would take the dump by running this command on the replica:
bash> mysqldump --single-transaction --quick --lock-tables=false --insert-ignore --all-databases --master-data=2 | gzip > data-for-replica.sql.gz
and after the MySQL dump is complete, I would restart the replica to let it catch back up:
mysql> START SLAVE;
My question is: since I'm using --single-transaction when doing my dump, can I parallelize these tasks:
- Stop replication, check coordinates, and then initiate the MySQL dump
- Re-start the replica in a separate shell while the dump is taking place
Would anything go wrong? Would I get inconsistent data and coordinates that would prevent me from creating the new replica in a sane state?
My hope would be to avoid having to wait for the dump to finish for a large database before restarting the replica that the backup is taken from. Since the dump is happening in a single transaction, any updates from the master would not be included in the dump, and hence the dump would be consistent with the coordinates I checked while the replica was stopped. Am I missing anything?