0

Is it possible for the client to use the slave when the master is down in mysql replication?

I have already set up a simple MySQL replication having a master and a slave.

The client connects to the master to access the database; any changes made to the master server is replicated onto the slave. How shall I configure the client so that when the master server is down, the client automatically connects to the slave server?

I am using MySQL Server 5.1 and MySQL workbench 5.2 CE. I edited the my.ini files for both master and slave.

The client uses a J2EE application.

What additional commands must I input in the master my.ini file to make the changes?

Also is there a way to increase or decrease the time interval between replications?

Mei
  • 4,590
  • 8
  • 45
  • 53

1 Answers1

1

Your last question is unclear - and irrelevant to the question posed in the title.

For configuring your client, that depends on the client, not the master database. Often, the change is hidden from the client by using a single IP and having one or the other system take over from the other when necessary.

The set up you are asking about is master fail-over: when the master dies, the slave can be promoted to master status and remain so until the true master returns. Returning the old master back to operations can be a little tricky - the replication needs to be preserved. It may even be easier to return the old master back to operations as a slave instead.

As far as the my.ini file goes, I could be wrong, but I don't think any changes are necessary unless you want the system to retain its master status (during a reboot) after a failover. I believe the changes are all made within MySQL itself.

More on this topic can be had from the book MySQL High Availability published by O'Reilly.

Mei
  • 4,590
  • 8
  • 45
  • 53