Mysql Server version: 5.0.77-log Source distribution

failoverMySQLreplication

I have a master(M)-slave(S) replication on MySQL. During a failover test, the master was brought down and the slave was made the master by doing STOP SLAVE; RESET MASTER;. Since there are only 2 servers (master and slave) I didn't have any other slave to change master to. On the master server the MySQL data files (ibdata files and bin logs) were deleted by mistake. Can someone please tell me how to bring the master up to speed and change it back to being the master server?
Thanks.

Best Answer

STOP SLAVE; RESET MASTER; is not the right way to do a failover. You can stop a slave if you want, but RESET MASTER will delete your own binary logs. You may be looking for RESET SLAVE; CHANGE MASTER TO MASTER_HOST=''; (RESET SLAVE ALL; since 5.5). The actual failover is not performed by mysql, but by an external entity, be it a proxy or a connector.

As you have resetted the master data and the slave binary logs, you need to perform a clone of the slave (current master) with its binary logs coordinates (with mysqldump or Percona XtraBackup) and set the replication in the other direction.

If you intend to do manual failovers, a master-master replication with one of the nodes in read-only mode is suggested. You also have software like MHA that can simplify the process.