* on 192.168.3.7 | 软件 | 版本 | 备注 | | --- | --- |--- | | centos| 7.5 | | | haproxy| | | ``` yum install -y haproxy [root@rabbitmq01 haproxy]# cat haproxy.cfg global log 127.0.0.1 local2 chroot /var/lib/haproxy maxconn 5120 user haproxy group haproxy daemon quiet nbproc 20 pidfile /var/run/haproxy.pid defaults log global mode tcp option tcplog option dontlognull retries 3 option redispatch maxconn 2000 clitimeout 60s srvtimeout 15s listen rabbitmq_cluster bind 0.0.0.0:5671 mode tcp option tcplog balance roundrobin #option tcpka server rabbitmq01 192.168.3.7:5672 check inter 5s rise 2 fall 3 server rabbitmq02 192.168.3.8:5672 check inter 5s rise 2 fall 3 server rabbitmq03 192.168.3.9:5672 check inter 5s rise 2 fall 3 listen stats bind 0.0.0.0:8100 mode http option httplog stats enable stats uri /rabbitmq-stats stats refresh 5s [root@rabbitmq01 haproxy]# service haproxy start Redirecting to /bin/systemctl start haproxy.service ``` * on 192.168.3.8 | 软件 | 版本 | 备注 | | --- | --- |--- | | centos| 7.5 | | | haproxy| | | ``` yum install -y haproxy [root@rabbitmq01 haproxy]# cat haproxy.cfg global log 127.0.0.1 local2 chroot /var/lib/haproxy maxconn 5120 user haproxy group haproxy daemon quiet nbproc 20 pidfile /var/run/haproxy.pid defaults log global mode tcp option tcplog option dontlognull retries 3 option redispatch maxconn 2000 clitimeout 60s srvtimeout 15s listen rabbitmq_cluster bind 0.0.0.0:5671 mode tcp option tcplog balance roundrobin #option tcpka server rabbitmq01 192.168.3.7:5672 check inter 5s rise 2 fall 3 server rabbitmq02 192.168.3.8:5672 check inter 5s rise 2 fall 3 server rabbitmq03 192.168.3.9:5672 check inter 5s rise 2 fall 3 listen stats bind 0.0.0.0:8100 mode http option httplog stats enable stats uri /rabbitmq-stats stats refresh 5s [root@rabbitmq01 haproxy]# service haproxy start Redirecting to /bin/systemctl start haproxy.service ``` 访问 http://192.168.3.7:8100/rabbitmq-stats http://192.168.3.8:8100/rabbitmq-stats ![](https://img.kancloud.cn/0e/97/0e97e32bbe1cebb40c444d5611e9dbad_1915x458.png)