Mysql – Setting up Master-Master Replication in MySQL on a live system

multi-masterMySQLreplication

I've just recently taken on the task of looking after our mySQL databases, and have been given the task of setting master-master replication. We have a live server which has a mySQL database which is constantly receiving data and a backup server which has been configured as a replication slave to the master. What I need to do now is set the live server up as a slave to the backup. I have an idea of what is necessary, and I guess I'm just looking for someone to confirm I've got it right before I go and do it (or tell me a better way of doing it).

  • Create slave user on backup-server
  • Grant replication privileges to the user
  • stop slave on backup-server
  • set database lock(read only) on live-server so no new data can be added (and hence replicated to backup)
  • Get master status from backup-server
    -open new ssh session to live-server and issue change master command to point at backup-server
  • start slave on live
  • unlock database on live
  • start slave on backup

Best Answer

  • create replication user on backup
  • configure replication on live as slave and backup as master
  • start slave
  • profit!