snippetsqlMinor
How to migrate from a MySQL master-slave setup to a master-master setup without downtime
Viewed 0 times
withoutdowntimeslavemigratemysqlmastersetuphowfrom
Problem
We have an existing master-slave MySQL replication setup where we would like to promote the second slave to a master in order to achieve a master-master setup with no or only minimal downtime.
Is it sufficient to do a
Is it sufficient to do a
SHOW MASTER STATUS on the slave and do a CHANGE MASTER TO ... on the current master or will this result in a replication error?Solution
On a basic level, yes. Just set up the current Master like you would any normal slave database.
However, there are some things to consider first.
Is the second slave set to
You probably want to set
This prevents the two masters from creating the same auto_increment primary keys.
You also want to make sure you have no replication filters (binlog-do-db, replicate-do-db etc) set up as they can cause problems too).
However, there are some things to consider first.
Is the second slave set to
READ-ONLY, as you want to avoid writing to both masters at once.You probably want to set
auto_increment_increment=2 and auto_increment_offset=1 on the first master, and auto_increment_increment=2 and auto_increment_offset=2 on the second master.This prevents the two masters from creating the same auto_increment primary keys.
You also want to make sure you have no replication filters (binlog-do-db, replicate-do-db etc) set up as they can cause problems too).
Context
StackExchange Database Administrators Q#134735, answer score: 4
Revisions (0)
No revisions yet.