1

I have a MySQL setup with one master (M1) and one slave(S1). Due to some unforeseen issue I need to promote my slave server to master and demote master to slave. My MySQL version is 5.6 in Linux.

Please let me know the exact process as this is the live website and need to make sure the downtime is much lesser.

Anand Shrestha
  • 41
  • 4
  • 12

1 Answers1

2

Firstly you need to make sure that data is identical on both nodes currently. If data is not identical you should take backup of current master and restore on current slave. Once this is done, you should run the following command on current slave -

mysql> show master status\G;

note down the file name and log position

Then run the following command on current master node -

CHANGE MASTER TO MASTER_HOST='IP of current slave',MASTER_USER='usrname for replication', MASTER_PASSWORD='password for replication user', MASTER_LOG_FILE='file name you noted in above step', MASTER_LOG_POS= Log position you noted in above step;

Now run following command on current master (slave after running above command)

mysql> start slave;

You can check the status of slave with command below -

mysql> show slave status\G;

Now point your application to new master.

  • you need to make sure that your slave has binary log enabled before you start. You also should reset slave on the old slave. – danblack Aug 19 '18 at 00:26