2

We currently have an alias assigned to our NIC for the purposes of managing a HA Proxy pair.

# cat /etc/sysconfig/network-scripts/ifcfg-eth0:proxy
DEVICE=eth0:proxy
BOOTPROTO=none
ONPARENT=no
TYPE=Ethernet
IPADDR=10.1.1.2
NETMASK=255.255.255.255
NM_CONTROLLED=no

This file exists on both nodes. When we want to switch which proxy is handling traffic, we do an ifdown eth0:proxy on the current primary, and an ifup eth0:proxy on the secondary. It's a fully manual process.

Apparently, RedHat has deprecated this way of assigning multiple IP addresses. Instead they recommend just adding the secondary IP to the main interface:

# ifcfg-eth0
...
IPADDR2=10.1.1.2
...

But there doesn't appear to be a 'nice' way to manage the process of bringing up the IP on the secondary box, and bringing it down on the primary like my example above.

We do not use NetworkManager either. That service has been stopped and disabled.

Is there a way to switch the active public address on both nodes without editing both configuration files and restarting the NIC, similar to how we were doing it before?

Also, is there a good way of automating the up/down process if, for example, the primary gets restarted? It'd be nice if the secondary could detect that the primary is gone, and automatically take over the VIP.

We don't want to have both HAProxies serving traffic at the same time by DNS load balancing, because the stickiness of backend servers is important.

Josh Smeaton
  • 1,330
  • 2
  • 19
  • 31
  • 1
    Things like Pacemaker are supposed to take care of this sort of thing for you. As for the IP, `ip addr (add|del) 10.1.1.2 dev eth0` – Michael Hampton Dec 21 '15 at 22:39
  • Does `ip addr add X` persist through a restart? Also, I could never get pacemaker working correctly on rhel for reasons I no longer remember. Is pacemaker still the recommended way? – Josh Smeaton Dec 21 '15 at 23:26
  • You put it in sysconfig as you described above as `IPADDR2` to make it persistent. – Michael Hampton Dec 22 '15 at 01:35
  • Pacemaker is indeed Red Hat HA's resource manager. Usually you let cluster resources be managed by such software. Clusters can be tricky, so you can roll your own simpler script. To make it automatic you would be re-implementing something like a HA cluster. – John Mahowald Dec 22 '15 at 08:53
  • 1
    Have you tried keepalived? It can manage virtual IP addresses (and failover) with fairly little configuration effort. And it also appears to be the preferred means of doing HA on RHEL 7: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Load_Balancer_Administration/s2-lvs-keepalived-haproxy-VSA.html – Jukka Dec 22 '15 at 21:03

0 Answers0