2

I am in the process of adding a new slave to a replicated MySQL setup. I'm proposing the following process:

  1. clone one of the nodes to a new VM
  2. start it with no networking
  3. stop mysql
  4. change the server-id in my.cnf to a new id
  5. restart mysql and networking

Should this work correctly? Or will MySQL get confused because it used to be a different server id?

OS: Ubuntu 10.10

VM Platform: VMWare 5

MySQL : Server version: 5.1.49-1ubuntu8.1-log (Ubuntu)

Magellan
  • 4,431
  • 3
  • 29
  • 53
Ben Holness
  • 914
  • 2
  • 10
  • 28

1 Answers1

2

I am unfamiliar with VMWare, but I am familiar with doing this process across arbitrary logical volumes. First, you have to clone the VM in such a way that your VM snapshot copies the server in a consistent state (like an LV Snap). You also need to be able to grab the slave's current replication coordinates as you begin your copy. Because of this, the following mechanism would be required:

  1. FLUSH TABLES WITH READ LOCK;
  2. SHOW SLAVE STATUS a. Retrieve Exec_Master_Log_Pos and Relay_Master_Log_File from this output, these are your coordinates to use when setting up replication on the new slave
  3. -- Begin creating snapshot
  4. UNLOCK TABLES;

Once this is done and the new server has been built from image, you will need to execute a CHANGE master statement on the slave to update these binlog coordinates:

CHANGE MASTER TO MASTER_LOG_FILE="${Relay_Master_Log_File from 2a}", MASTER_LOG_POS=${Exec_Master_Log_Pos from 2a};

This method would work with an LV snaphsot for exmaple. Some tools such as hollandbackup support this style of LVM copy: http://wiki.hollandbackup.org/mysqllvm

Tyler
  • 21
  • 3