Mysql – Doubts on Setting up Master-Master replication (Percona)

MySQLmysql-5.6perconapercona-serverreplication

I have two 5.6 Percona servers in which I'm planning to setup Active master- Passive master replication. Secondary master will be in read-only mode.

Caveat is that the servers in which i'm going to setup is live databases. Master is already running with server-id=1 and it is in place. Secondary master is newly created instance.

Now to backup the production master and copy it to the secondary master, is it mandatory that I need to take backup the live database and then copy it to secondary? Or will it suffice if I take last night's backup?

Also, when I set the Active master to be the slave for secondary, will it impact my production?

I know I need to do this off-live hours but situation demands, hence I wanted to reconfirm before proceeding.

Please highlight on what impact that could do in live database for setting up this replication.

Best Answer

Set up slave

You can set it up from the nightly backups. That's actually a common practice to provision slaves from backups to also have them tested. You can go back as far as you have binlogs stored on the master (expire_log_days variable).

The impact of having a slave starting from older backup is that it has to fetch the logs from the master but that shouldn't be a heavy operation. Unless your master is already on the edge you shouldn't really notice it. The other impact is that it will take longer for the server to catchup which is of course expected.

Switchover

Switchover can have some impact if you use auto-increment IDs and your passive master is not fully caught up with replication. Best is to make the old active read-only for a second or two while checking the passive for master position. Once there is no change you can move change it to be the active and make it writeable.

Depending how you point to the active master (DNS switch for example) it might take some time during which time both masters will accept writes and the old active being read-only will report errors.

I hope this helped.