1

This is all new to me. Please bear with me. Sorry if I don't phrase my problem correctly. I'd like to set ip floating to use HAproxy and Keepalived.

I have the following ips:
LB1: 192.168.1.27 #first load balancer
LB2: 192.168.1.32 #second load balancer
www1: 192.168.1.28 #first web server
www2: 192.168.1.29 #second web server
floating ip: 192.168.1.200

When I turn off load balancer 1 (LB1), traffic is not getting redirected to floating ip. I don't know what to check so I can make this whole setup run successfully. I suspect that LB2 is the problem (apart from me:)) as the floating ip doesn't do its job when LB1 is down.

I also followed the checking process section on the link below '8. Verify proper failover' but to no avail: How to create Floating IP and use it to configure HAProxy. Individually, the 5 ips work fine only when HAproxy is on. That's all I can say.

Could you please help me? Thanks.

EDIT

My config:

HAPROXY INSTALL on lb1

global
    log 127.0.0.1 local2
    daemon
    stats socket /run/haproxy/admin.sock mode 660 level admin
    stats timeout 30s
    user haproxy
    group haproxy

defaults
    log global
    mode http
    option httplog
    timeout connect 5000
    timeout client 50000
    timeout server 50000
    retries 3
    errorfile 400 /etc/haproxy/errors/400.http
    errorfile 403 /etc/haproxy/errors/403.http
    errorfile 408 /etc/haproxy/errors/408.http
    errorfile 500 /etc/haproxy/errors/500.http
    errorfile 502 /etc/haproxy/errors/502.http
    errorfile 503 /etc/haproxy/errors/503.http
    errorfile 504 /etc/haproxy/errors/504.http

listen stats
    bind :1936
    stats enable
    stats hide-version
    stats realm Loadbalanced\ Servers
    stats uri /haproxy?stats
    stats auth haproxy:haproxy

frontend http-in
    bind *:80
    default_backend webservers

backend webservers
    balance roundrobin
    option httpchk GET /haproxy_check
    stick-table type ip size 20k peers mypeer
    server www1 192.168.1.28:80 cookie LSW_WWW1 check inter 500 fall 3 rise 2
    server www2 192.168.1.29:80 cookie LSW_WWW2 check inter 500 fall 3 rise 2

peers mypeer
    peer lb1hostname 192.168.1.27:1024
    peer lb2hostname 192.168.1.32:1024 backup

HAPROXY install on lb2:

global
    log 127.0.0.1 local2
    daemon
    stats socket /run/haproxy/admin.sock mode 660 level admin
    stats timeout 30s
    user haproxy
    group haproxy

defaults
    log global
    mode http
    option httplog
    timeout connect 5000
    timeout client 50000
    timeout server 50000
    retries 3
    errorfile 400 /etc/haproxy/errors/400.http
    errorfile 403 /etc/haproxy/errors/403.http
    errorfile 408 /etc/haproxy/errors/408.http
    errorfile 500 /etc/haproxy/errors/500.http
    errorfile 502 /etc/haproxy/errors/502.http
    errorfile 503 /etc/haproxy/errors/503.http
    errorfile 504 /etc/haproxy/errors/504.http

listen stats
    bind :1936
    stats enable
    stats hide-version
    stats realm Loadbalanced\ Servers
    stats uri /haproxy?stats
    stats auth haproxy:haproxy

frontend http-in
    bind *:80
    default_backend webservers

backend webservers
    balance roundrobin
    option httpchk GET /haproxy_check
    server www1 192.168.1.28:80 cookie LSW_WWW1 check inter 500 fall 3 rise 2
    server www2 192.168.1.29:80 cookie LSW_WWW2 check inter 500 fall 3 rise 2

KEEPALIVED ON LB1

vrrp_script chk_haproxy {
    script "pidof haproxy"
    interval 2} 
vrrp_instance VI_1 {
    interface eth0
    state MASTER
    virtual_router_id 51
    priority 200
    virtual_ipaddress {
            192.168.1.200
    }
    track_script {
            chk_haproxy
    }}

KEEPALIVED ON LB2

vrrp_script chk_haproxy {
    script "pidof haproxy"
    interval 2}

vrrp_instance VI_1 {
    interface eth0
    state BACKUP
    virtual_router_id 51
    priority 100
    virtual_ipaddress {
            192.168.1.200
    }
    track_script {
            chk_haproxy
    }}

On LB1 and LB2, in Keepalived:

nano /etc/sysctl.conf

added net.ipv4.ip_nonlocal_bind=1

sysctl -p

on lb1:

sudo service keepalived alived stop then checked if lb2 is working. It is!!! But when Haproxy on LB1 is down, traffic still doesn't get redirected to LB2.

Community
  • 1
  • 1
jacquesm
  • 11
  • 1
  • 3

1 Answers1

0

It could indicate problem with arp update when failover ip, check arp table on your devices if floating ip points to lb2 mac addr

witalis
  • 34
  • 2