MySQL Replication Switch Master/Slave
It is good idea to turn of MySQL server at start. So that if the master goes down it does not start by itself when it comes back up.
Follow these steps on the slave :
Note: The Slave also has to be setup with binary logging enabled. In order to this you can add the following line to your my.cnf file :
log-bin = /var/lib/mysql/name-bin
-
Login to msyql
-
Stop Slave;
-
Reset Master;
-
Show master status \G;
Note the binary log position and the name on the result. This will be needed on the slave.
On the Master :
-
Start mysql
-
Login to mysql
3.Slave stop;
- CHANGE MASTER TO MASTER_HOST=’masterservername or ip’, MASTER_LOG_FILE=’binarylogname’, MASTER_LOG_POS=’binarylogposition from step 4 above’;
4.Slave start;
It is also good idea to clear the logfiles on slave.
cd /var/lib/mysql
rm relay
rm master.info