简体   繁体   中英

MySQL Master-Slave-Slave Configuration

Quick questions about MySQL Master-Slave-Slave set-ups:

I currently have a Master-Slave set up right now and I would like to add another slave. Would it be possible to clone the server running the slave, and then spin up a new server with the image from the slave, and have it pick up right where it left off? So whatever the binlog was at the time of the copy it would just run until it catches up with the master?

Ideally - I'm trying to start another slave the connects to the master without shutting down the Master for a backup. Any advice or guidance would be great. Thanks!

Yes, you can shutdown slave instance, and copy all it's data to another slave (including logs).
Don't forget to edit my.cnf on second slave (you should change server-id )
Then start both slave servers

Yes this is possible. The best way would probably be to temporarily pause the replication on the slave, determine the master binary log position information, then make your dump from the replica while replication is still paused (and no other data is changing on the replica). After the dump is complete you can restart the replica.

On the new server, just install the dump, set the binlog coordinates and start up the replication. A word of caution though. Make sure your settings for purging the binary logs on the master will allow for retention of the binary logs for long enough for you to do this set up process and get the new slave caught up before the bin logs are purged.

Here's a good tutorial on how to setup multiple replication slaves for a master server: http://arcib.dowling.edu/cgi-bin/info2html?%28mysql%29replication-howto

It doesn't explain your scenario, but gives important hints: you must assign a unique server-id to your second slave.

Regarding your problem: If your masters binary log is kept long enough, you should not get into trouble. Just shutdown your slave for a moment, clone it and write down: MASTER_LOG_FILE and MASTER_LOG_POS of the slave; then restart the original slave and setup the second slave correctly: that means with that given MASTER_LOG_POS and *_FILE set and a unique server-id in my.cnf;

Then start up your second slave. Use "START SLAVE" to start the replication and then have a look at "SHOW SLAVE STATUS;"

Regards, Stefan

PS: Cannot promise this to work, but I'm quit sure it should do.

You can use existing mysql slave to make a new one just do the following steps,

  1. Stop replication on slave.
  2. execute show slave status; and note these values Master_Log_File: master-bin.000002 & Read_Master_Log_Pos: 1307
  3. Take mysqldump and restore it on new mysql slave server, you can copy my.cnf file from existing mysql slave server and just change server-id .
  4. execute change master to command on new slave server providing details of mysql master server and log file name and log position which we obtained from existing mysql slave.
  5. execute start slave; on existing mysql slave.
  6. to verify slave status run show slave status .

that's it you have a new mysql slave server!!

Good luck !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM