I had the same problem more than once. I solved it
with a (not-so) simple perl script but the idea is
very simple: swap the machines!
scenario #1: master and slave running
- master is used for writes, slave for reads,
replication goes well. you have a DNS entry for
MASTERDB.domain and SLAVEDB.domain.
scenario #2: master fail, slave stop receiving data
- now, you should have something to warn you the
master went down, otherwise you could spend much time
until find out by yourself.
- since the time you know, the idea is to change
MASTERDB.domain pointing to the same as SLAVEDB.domain
so both reading and writing is happening on the slave
- at this time you broke the chain between what had
on master and slave, so replication will not happen
- now you can fix your master.
- change the master config to stop doing log-bin and
start as a slave using SLAVEDB.machine as master.
- edit my.cfg on slave's machine to start log-bin
and stop trying to get data from master.
- restart the slave, now as master.
- restart the master, now as slave and issue a LOAD
DATA FROM MASTER
- start the old master (new slave) slave status and
- point SLAVEDB.domain to the old master machine.
scenario #3: machines swapped, same scenario
- now you have exactly the same thing as before, but
your machines are swapped. You can do it as many times
as you want.
- If the machines are the same you can keep that
scenario untill the new master breaks.
- If the (old) master db is much better you can do
the same trick again on a low-traffic hour.
This swap may take you no more than an hour, plus the
time to fix the broken machine.
The trick with domains could also be done using IP
alias on the interface if you're connecting the
machines using IPs. I used IPs instead of names.
hope that helps,
--- jalil@stripped wrote:
> We have one master and one slave database and use
> the slave for reads.
> If for some reason our master goes down,
> we would like to make our slave the master and use
> it for both writes
> and reads and then switch to the original
> when the master is up, which includes updating the
> master copy. Limited
> downtime/locking of the second database is OK.
> Is this something that is easy to do or recommended?
> If so, what steps
> we need to go through or where can I find isome
> nformation regarding
> this? If not, what other approachs are there
> (assuming we only have two
> machines w/ above configuration).
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
Yahoo! Acesso Grátis - Internet rápida e grátis.
Instale o discador agora! http://br.acesso.yahoo.com/