RHEL7: Configure a high available load-balancer.

Presentation

For this tutorial, you need 2 virtual/physical servers for the load-balancers and 2 virtual/physical servers to load-balance.

In addition to the 4 IP addresses needed by the servers themselves, a fifth virtual IP address (VIP) is necessary. The two load-balancers and the VIP need to be in the same network segment.

Piranha has been replaced in RHEL7 with HAProxy and keepalived. For this reason, HAProxy will be used as load-balancing software, keepalived as high availability solution and apache as software to load-balance.

Here is the addressing schema chosen to write into the /etc/hosts file of each server:

192.168.0.100 vip

192.168.0.101 haproxy1

192.168.0.102 haproxy2

192.168.0.103 httpd1

192.168.0.104 httpd2

HAProxy Installation

On the haproxy1/haproxy2 servers, execute the following instructions:

Install the HAProxy package:

# yum install -y haproxy

Edit the /etc/haproxy/haproxy.cfg file, replace the line “frontend main *:5000” with “frontend main *:80” and comment out the line “use_backend static if url_static“.
At the end of the same file, remove the lines starting with “server app” and replace them with the following lines: