V
V
vlarkanov2017-08-25 10:21:55
linux
vlarkanov, 2017-08-25 10:21:55

Mysqldump for master-slave: how to dump and upload several databases at once?

Hello! There is a server1 on which 6 bases are twisted. You need to set up a slave where 3 of them will be replicated. I do this:
I do a DB1 dump

mysqldump -u root --master-data=2 --single-transaction DB1 > DB1.sql

Then I copy this dump to server2, import
mysql -u root DB1 < DB1.sql

Then I start (using the line CHANGE MASTER TO MASTER_LOG_FILE='mysqld-bin.000ххх, MASTER_LOG_POS=хххххххх;) from the dump to replicate the first base until it catches up with the master's position.
Then I stop replication, memorize the binglog and the position, fill in the second base, replicate it (the first one is not replicated at this time) to the position where I stopped the first one .... Here is a detailed description of how and what I do konotest.ru/?p= 91
I understand how to dump three bases at once
mysqldump -uroot -p -B DB1 DB2 DB3 > databases.sql

- but the question is how to pour them into the slave and immediately start replication for all three? It is critical to do it through mysqldump.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Shatokhin, 2017-08-25
@Sovigod

Do a dump:
mysqldump --all-databases -u root --master-data=2 --single-transaction > DBs.sql
all databases will be there at once. No need to list them on the command line.
Fill in the same way:
mysql -u root < DBs.sql
After start replication
PS I used to dump something like this
mysqldump --flush-privileges --flush-logs --triggers --routines --events --hex-blob -- extended-insert --complete-insert --no-autocommit --lock-all-tables --master-data=2 --all-databases

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question