Multimaster Keepalived Configuration with Virtual IP and Load Balancing – Guide

high-availabilitykeepalivedlinuxvirtual-ip

Here are requirements:
1. High Availability
2. Load Balancing

First configuration
1. Two linux servers have been configured with one static IP for each: 10.17.243.11, 10.17.243.12
2. Keepalived has been installed and configured with one VRRP instance to provide one virtual IP (10.17.243.10 as VIP, 10.17.243.11 as master and 10.17.243.12 as backup).
3. Everything works fine. The VIP is assigned to the master server (10.17.243.11) as long as it is up and running. As soon as it goes down, the VIP will be assigned to the backup server (10.17.243.12).
4. The problem here is all communication goes to the master server.

Second configuration
1. I found active-active configuration for Keepalived which is possible by defining more than one VRRP instance. So that both server have two IPs (real 10.17.243.11 and virtual 10.17.243.10 for server #1 and real 10.17.243.12 and virtual 10.17.243.20 for server #2.
2. Everything works fine. we have two VIPs which are accessible (HA). But all communication coming to each IP still goes to one single machine (either server #1 or #2 depending on the IP). However I found some tricks on the DNS to overcome this limitation. But it's not acceptable in our case.

Question:
Is there any way to have one virtual IP which is assigned to both servers? By that I mean both servers are handling some part of workload (like the thing we do in web server load balancing)? By using either keepalived or some other tools?

Thanks in advance.

Best Answer

After some investigations, I found CLUSTERIP extension of IPTABES useful for this purpose. Just google it.

For me, at first, it was a bit hard to configure and get the system up. But finally based on a PDF document by Michael Schwartzkopff I managed to do. Unfortunately I forgot the link on the web. However I have the document, just in case. More information might be useful on another question of mine in this regard:

iptable CLUSTERIP doesn't work