1

I have a CENTOS server running a PHP, Apache and MySQL site. I want to create a second server that can do the following:

  1. Keep the databases between server 1 and server 2 synched (preferably in realtime as transactions happen).
  2. Can be set at a domain level (or some other way) to switch to the second server should anything break on Server 1?
  3. Avoid the use of a 3rd Load Balancing server?

The reason why I don't want the third load balancer, is because I don't want to be in a situation where the load balancer itself goes down. I want to only rely on the actually working solution servers.

Is this possible and what is the easiest way?

My biggest concern is that this can't be done on a DNS level due to propogation, so I do think there might have to be some kind of 3rd intermediary that determines where the traffic goes?

2

1 Answer 1

1

For MySQL, use replication to keep the backup server in sync with the primary. See the documentation, and keep in mind that replication is asynchronous and can lag under even moderate load.

PHP and Apache are stateless services that don't need to be synced, other than their configurations.

If you don't want a loadbalancer, you can use heartbeat to manage a virtual IP between the two servers. If the primary server goes down, the secondary will assign itself the IP and continue to serve traffic. Note that this will only monitor the heartbeats between the two heartbeat services, not the running state of mysql/apache/etc.

what would host the portion that decides which server gets used?

Webserver clients would connect to the virtual IP, or a hostname that resolves to that IP, so traffic would only ever hit the server that has that vip, and the other server would be standby only.

Configure PHP on both servers to connect to MySQL on localhost, so if the first server dies, the second one will assume that IP and continue. Keep in mind, though, that regular one-way MySQL replication means that as soon as you start writing to the slave, the original master will be forever out of date and need to be rebuilt. You could use master-master replication, or Percona XtraDB Cluster, but those are more complicated to set up.

2
  • My concern is what would host the portion that decides which server gets used? Apr 16, 2013 at 8:08
  • updated to answer your question. Apr 18, 2013 at 2:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .