Creating a new slave to support your system expansion is not easier: coping large data files over the LAN, recovering replication, etc.
Fortunately, virtualization and SAN help us do it easier and faster.
Lucky us, Cloud Computing make it even easier.
Adding a New Slave is Easier than Ever
- Select an existing slave that can be reboot w/o affecting the service.
- Take the slave out of the production environment.
- Stop the MySQL slave and perform a read lock: SLAVE STOP;FLUSH TABLES WITH READ LOCK;
- Create an AMI based on this instance using AWS console or API.
- Recover the instance upon AMI creation completion and get the slave back to production: UNLOCK TABLES;SLAVE START;SHOW SLAVE STATUS\G
- Create a new slave based on the AMI
- Launch a new slave using the AWS console or API.
- Change the server's /etc/my.cnf file to fit a new slave instance:
- Change the server-id=N value to a new numeric value.
- Set relay-log='server-relay-bin' to the original slave server relay log name. (if you want to make it even easier, configure in the first slave's my.cnf relay-log=mysqld-relay-bin, and you'll be able to avoid this step).
- Restart the MySQL instance: sudo /etc/init.d/mysql restart
- Recover the MySQL: UNLOCK TABLES;SLAVE START;SHOW SLAVE STATUS\G
- Add this new slave to the production environment.
Expanding your business today is easier w/o the need for file copy or any other tedious action.