HAProxy 负载均衡器、VIP 和 Keepalived 设置的可访问性问题

HAProxy 负载均衡器、VIP 和 Keepalived 设置的可访问性问题

我使用 2 个 HAProxy 服务器,它们具有虚拟 IP (VIP) 和 Keepalived。虽然我可以访问活动的 HAProxy1 服务器,但当 HAProxy2 处于活动状态时,我遇到了可访问性问题。如何解决 HAProxy2 处于活动状态时的访问问题?

我已经配置了 VIP 和 Keepalived,通常我可以有效使用 HAProxy 负载均衡器。但是,当 HAProxy2 处于活动状态时,我遇到了访问问题。Keepalived 会如何影响这种情况,或者我如何识别 HAProxy 配置中的潜在问题?

我可以采取哪些步骤来排除故障并解决此问题,或找出问题的根源?我非常感谢您提供的任何指导。

HAProxy1-2 配置:

global
    maxconn 100
    log /dev/log    local0
    log /dev/log    local1 notice
defaults
    log global
    mode tcp
    retries 2
    timeout client 30m
    timeout connect 4s
    timeout server 30m
    timeout check 5s

listen stats
   mode http
   bind *:7000
   stats enable
   stats uri /

frontend a_listen_fe
bind *:5911
acl is-read-service-dead nbsrv(standby) lt 1
use_backend postgres if is-read-service-dead
default_backend standby


listen postgres
       bind 10.5.70.190:5000
       option httpchk
       http-check expect status 200
       default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
       server node1 10.5.70.193:5432 maxconn 1000 check port 8008
       server node2 10.5.70.194:5432 maxconn 1000 check port 8008
       server node3 10.5.70.195:5432 maxconn 1000 check port 8008

 listen standby
       option httpchk OPTIONS/replica
       http-check expect status 200
       default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
       server node1 10.5.70.193:5432 maxconn 1000 check port 8008
       server node2 10.5.70.194:5432 maxconn 1000 check port 8008
       server node3 10.5.70.195:5432 maxconn 1000 check port 8008

Keepalived配置文件

 global_defs {
 }
 vrrp_script chk_haproxy { # Requires keepalived-1.1.13
     script "killall -0 haproxy" # widely used idiom
     interval 2 # check every 2 seconds
     weight 2 # add 2 points of prio if OK
 }
 vrrp_instance VI_1 {
    interface ens192
    state MASTER # or "BACKUP" on backup
    priority 101 # 101 on master, 100 on backup
 virtual_router_id 51
 advert_int 1
 authentication {
    auth_type PASS
    auth_pass 1234
 }
 virtual_ipaddress {
    10.5.70.190/24  label ens192:0
 }

 unicast_src_ip 10.5.70.191     # This node
 unicast_peer {                # Other nodes
    10.5.70.192
 }


 track_script {
    chk_haproxy
 }
 }

谢谢!

答案1

我无法从主服务器访问 VIP 5000 端口。[postgres@cbspgmaster log]$ traceroute 10.5.70.190 5000 traceroute to 10.5.70.190 (10.5.70.190), 30 hops max, 5000 byte packets

相关内容