- Login to existing mysql server.
- Change the configuration
/etc/my.cnf
, add the following server-id=1, log-bin=mysql-bin
- To make sure your configuration is correct, run
mysqld --verbose
- For the mysql process to pick up these, you need to run
sudo service mysql restart
and verify with mysqladmin variables
.
- Take a consistent snapshot of mysql. Keep a note of these values --
master_log_file, master_log_pos
- Start a new server with this volume (from snapshot).
- Edit
/etc/my.cnf
with server-id=2
- Restart mysql
- On cli,
STOP SLAVE;
CHANGE MASTER TO
MASTER_HOST='<ip-address>',
MASTER_USER='<username>',
MASTER_PASSWORD='<password>',
MASTER_LOG_FILE='<value of master_log_file>',
MASTER_LOG_POS= <value of master_log_pos>;
START SLAVE;
show slave status
will show the lag between master and slave. Make sure they're in sync.
- Point your application to slave.
- Once writes are coming to slave, and master is idle
On slave cli: stop slave; reset slave;
- Terminate your master. New slave is now a standalone mysql server.