MySQL Forums
Forum List  »  InnoDB

Re: Master database crashed
Posted by: Rick James
Date: November 25, 2011 12:05PM

Yes, the Slave can be "promoted" to be the Master. Maybe the dead master can be "demoted" to slave.

But, changing the former Master to be a Slave will be difficult after you start writing to the newly-promoted machine -- unless you have already taken some steps to make this easier. Without those steps, it will be the same as having a Master (the promoted Slave) with no slaves. Let's call that the "first slave task".

A better situation, to start with Dual-Master -- That is, each server thinks it is a Master and a Slave. (More below)

In any case, if the dead machine cannot be recovered, you will need to do the "first slave task".

First slave task (some details left out). Note: Either way requires some downtime (a lot of downtime if the data is huge) --
Plan A:
* Stop the Master
* Copy the mysql tree from the master to the slave
* Start the master
* CHANGE MASTER to point the slave to binlog that was created after the previous step.
* etc
Plan B:
* mysqldump --single-transaction --master-log-pos --all-databases etc
* load that on the new machine
* CHANGE MASTER to point the file & position captured by mysqldump.
* etc
If you can set up the first slave before inserting any data, there are fewer steps.

Turning Master-Slave into Master-Master (perhaps some details missing)
* binlogging on -- If not already on, do it now, and restart the Slave!
* server_id different on the two. (Of course, Master-Slave would be broken if this were not done.)
* log_slave_updates is on on both. (A common omission!)
* CHANGE MASTER on _Master_ to make it a Slave to the other machine. There is no traffic in that direction (yet), but setting this up _now_ makes failover much simpler.
* Writes should go _only_ to one server. When that crashes, change the writes to go to the other server. Writing to both Masters leads to a lot of other issues.
* etc.

Read the online manual about Replication. It says a lot more than I have said here, but hopefully my notes will help you focus on the parts you need.

Options: ReplyQuote


Subject
Views
Written By
Posted
2927
November 21, 2011 12:55PM
1127
November 22, 2011 09:16AM
1121
November 22, 2011 04:41PM
1090
November 23, 2011 08:09PM
987
November 24, 2011 02:18PM
Re: Master database crashed
1465
November 25, 2011 12:05PM
1173
November 28, 2011 10:30AM
1003
November 30, 2011 10:23AM
933
December 05, 2011 11:23AM
1147
December 09, 2011 12:05PM
948
December 14, 2011 11:19AM
1122
December 15, 2011 09:33AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.