Hi all,
I need to document the switch between master and slave
and I want to double check if the outlined procedure is correct.

We have a simple master slave replication setup on OEL 5.5 and MySQL 5.5.13.


Original config: machineA master, machineB slave.
Target: machineB master, machineA not operational.

On the master:

1. flush logs on the master (only if it's accessible, of course).

On the slave:

2. stop slave io_thread
3. Wait until show processlist reports "Has read all relay log".
4. stop slave
5. reset master
6. change master to master_host='' and reset slave (only to be sure that the slave couldn't be started easily by mistake)
7. Start the application and checK if everything's OK

Now I should have only machineB operational,
I don't care for the state of machineA at this point.

To restore the initial state: machineA master, machineB slave:

1. Stop the application (assuming that's not a problem).
2. Generate a consistent dump on machineB:

mysqldump -u username -ppassword -A -x > dump_file

3. Import on machineA

mysql -u username -ppassword < dump_file

4. On machineA after the import:

reset master;
change master to master_host=''; # just in case, I prefer to have all info reset for safety
reset slave;                                          # see above
flush tables with read lock; # just in case, because there are no connections but mine at this time show master status; # just in case, it should be 4, right after the reset master command

5. On machineB (the slave):

change master to
master_host='machineA',
master_user='<my_rep_usr>',
master_password='<password>',
master_log_file='mysql-bin.000001',
master_log_pos=<pos>;

master_log_file and master_log_pos should be unnecessary because after the reset master they should correspond to the default values
of change master command, but again, it's just for safety.

Am I missing something?


Best regards
Dimitre




Reply via email to