Automatic Failover on a low budget

I am on a very low budget here. So this is my plan.

I will have exactly 2 VPS in the same datacenter. Both will be exact copies with glusterfs and galera configured to replicate db and application and config files across both servers.

I won't be using a nodebalancer - I am not looking for a load balancer. Though I use 2 servers, I expect only one to be actually used "active".

The second server, though exact copy, will act as a passive node - not doing anything at all except holding the replicated files and DBs.

What I want to do is:

  1. Both Server A & B will be up and running
  2. All requests will be routed only to Server A's IP. Hence everything will be serviced by Server A alone
  3. When server A crashes or is not responding, I need Server B to take over and start serving. This is where I hope I can share the IP from A to B so that the requests are served by B (using Linode's IP Sharing feature).
  4. This would continue until server B crashes (by that time I would bring up server A) and then server A would take over the IP.

Will this work?

Do I need to configure Keepalived for this? How do I do it?

2 Replies

The short answer is yes, this setup will work :)

The long answer is a bit more complicated. You'll need to set up a few different configurations to ensure replication and failover, as per the recommendations for high availability.

IP Sharing

IP Sharing, when configured in the Cloud Manager, gives Server B "permission" to utilize Server A's IP address in the event that Server A fails. This doesn't allow Server B to know that Server A fails, or provide configurations for replication, but it serves as the base for your highly available setup.

In order to utilize IP Sharing, you can follow these instructions to navigate to your first Linode's Networking tab and select the Linode you wish to share the IP address with.

Replication with GlusterFS

Now your two Linodes have the capability to share an IP address. However, they may not be sharing data, which isn't helpful for a high availability site. This is where GlusterFS comes in. GlusterFS takes care of replicating your filesystem, so that files added to Server A will be placed on Server B as well. We provide instructions here for configuring a GlusterFS setup.

More Replication with Galera

We've covered sharing an IP address and uploaded data; however, we also need to replicate your website's database. This is where Galera comes in. Galera provides multi-master replication for MySQL and other databases. Galera also allows you to continue writing to your cluster even if one master fails, which is not possible with standard MySQL replication. We have instructions for setting up Galera here.

Keepalived for Balancing

We have a nice setup already, but your Linodes still don't know how to complete the entire failover process. This is where Keepalived comes in. You can use HAProxy instead of Keepalived; this is personal preference depending on the goal of the user and their production setup structure.

Keepalived takes care of monitoring and failing over the high availability configuration using the IP sharing service we set up earlier. You will also need to disable SELinux in order to permit Keepalived to work properly. Once Keepalived is configured, if Server A were to go down, your site would stay up on Server B. Instructions for configuration can be found here.

Once each of these steps are completed, your website will meet each of the components of high availability: redundancy, monitoring, and failover.

I have a question on this. So sever A fails, server B picks up. Changes are made on server B during A's downtime, do these changes get replicated back to A when it comes back online.

Is this setup usable for email redundancy as well or is this for websites only?

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct