haproxy.cfg
defaults
mode http
log global
option tcplog
option dontlognull
option http-server-close
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
#---------------------------------------------------------------------
# static backend for serving up images, stylesheets and such
#---------------------------------------------------------------------
#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------
listen rabbitmq_cluster
bind :8888
mode tcp
balance roundrobin
server node01 192.168.0.200:5672
server node02 192.168.0.201:5672
server node03 192.168.0.202:5672
listen monitor
bind :6666
mode http
stats enable
stats uri /stats
listen rabbitmq_admin
bind :9999
server node01 192.168.0.200:15672
server node02 192.168.0.201:15672
server node03 192.168.0.202:15672
运行状态:
[root@ha-kp-2 ~]# systemctl status haproxy
● haproxy.service - HAProxy Load Balancer
Loaded: loaded (/usr/lib/systemd/system/haproxy.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2021-04-27 05:45:15 EDT; 9min ago
Main PID: 1542 (haproxy-systemd)
CGroup: /system.slice/haproxy.service
├─1542 /usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid
├─1543 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
└─1544 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
Apr 27 05:45:15 ha-kp-2 systemd[1]: Started HAProxy Load Balancer.
Apr 27 05:45:15 ha-kp-2 systemd[1]: Starting HAProxy Load Balancer...
Apr 27 05:45:15 ha-kp-2 haproxy-systemd-wrapper[1542]: haproxy-systemd-wrapper: executing /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
[root@ha-kp-2 ~]#
端口
[root@ha-kp-2 ~]# ss -tlunp |grep haproxy
udp UNCONN 0 0 *:52789 *:* users:(("haproxy",pid=1546,fd=6))
udp UNCONN 0 0 *:33346 *:* users:(("haproxy",pid=1544,fd=6),("haproxy",pid=1543,fd=6))
tcp LISTEN 0 128 *:9999 *:* users:(("haproxy",pid=1546,fd=8))
tcp LISTEN 0 128 *:9999 *:* users:(("haproxy",pid=1544,fd=8))
tcp LISTEN 0 128 *:8888 *:* users:(("haproxy",pid=1546,fd=5))
tcp LISTEN 0 128 *:8888 *:* users:(("haproxy",pid=1544,fd=5))
tcp LISTEN 0 128 *:6666 *:* users:(("haproxy",pid=1546,fd=7))
tcp LISTEN 0 128 *:6666 *:* users:(("haproxy",pid=1544,fd=7))
[root@ha-kp-2 ~]#