Hi ,
keepalived persistence_timeout settings causing break the load balancer. I am not sure. That is what I observe. Maybe I have missed out some configurations, Please help.
Please allow me to explain the steps that I have followed to configured the load balancer.
I have configured ipvsadm + keepalived in CentOS 7 on Virtualbox ENV. So the host OS is Windows 11.
Host Network - 192.168.1.0./24
So I prepared the load balancer testing environment in multiple centos nodes in VirtualBox.
Network I used:
Bridge Adapter - 192.168.1.0/24 (Same as host network and it has internet access) Host only adapter - 10.11.12.0/24 (Isolated with limited access, and doesn’t have internet access)
Configured two CentOS nodes as LB Master and Backup VMs in the virtualbox.
-
192.168.1.4/24 --> LB Master NIC 1, IP
-
192.168.1.5/24 --> LB Basckup NIC 1, IP
-
192.168.1.100/24 --> VIP of NIC 1
-
10.11.12.4/24 --> LB Master NIC 2, IP
-
10.11.12.5/24 --> LB Backup NIC 2, IP
-
10.11.12.100 --> VIP of NIC 2
enabled net.ipv4.ip_forward = 1 in /etc/sysctl.conf of both LB Nodes.
Real Servers
configured two dummy interfaces in each Real Servers.
[dummy0] [ipv4] address1=192.168.1.100/32 method=manual route1=192.168.1.100/32
[dummy1] [ipv4] address1=10.11.12.100/32 method=manual route1=10.11.12.100/32
net.ipv4.conf.dummy0.arp_ignore = 1 net.ipv4.conf.dummy0.arp_announce = 2 net.ipv4.conf.dummy1.arp_ignore = 1 net.ipv4.conf.dummy1.arp_announce = 2
Keepalived master/backup:
lb_algo rr
lb_kind DR
#persistence_timeout 300
protocol TCP
Testing:
ipvsadm -Lnc
TCP 11:51 ESTABLISHED 192.168.50.13:35300 10.11.12.100:5544 10.11.12.4:5544 TCP 11:00 ESTABLISHED 192.168.50.13:35300 10.11.12.100:5544 10.11.12.5:5544 TCP 06:45 ESTABLISHED 192.168.1.35:60604 192.168.1.100:80 192.168.1.4:80 TCP 14:45 ESTABLISHED 192.168.1.35:60831 192.168.1.100:80 192.168.1.5:80 TCP 11:45 ESTABLISHED 192.168.1.35:60782 192.168.1.100:80 192.168.1.4:80 TCP 07:45 ESTABLISHED 192.168.1.35:60620 192.168.1.100:80 192.168.1.5:80 TCP 12:45 ESTABLISHED 192.168.1.35:60799 192.168.1.100:80 192.168.1.4:80 TCP 09:45 ESTABLISHED 192.168.1.35:60663 192.168.1.100:80 192.168.1.5:80
From host windows machine:
C:\Users\luke>curl 192.168.1.100 WebServer-01
C:\Users\luke>curl 192.168.1.100 WebServer-02
So at this step, I enabled the persistence_timeout
C:\Users\luke>curl 192.168.1.100 WebServer-02
C:\Users\luke>curl 192.168.1.100 WebServer-02
Then the request always divert to a one RS. Here it is WebServer-02. Never hit to WebServer-01. May I know what has been the issue? What I have done wrong?
Thanks in advance, Luke.