用Haproxy來做RabbitMQ叢集的負載均衡
阿新 • • 發佈:2019-01-08
閒話
本文講述在RabbitMQ叢集的基礎下,用Haproxy來做負載均衡,node6,node7,node8這3臺機器已經組成一個RabbitMQ叢集了,在node9機器上配置Haproxy來做負載均衡。
配置HAProxy
下載
解壓
tar -xzvf haproxy-1.7.1.tar.gz
編譯
cd haproxy-1.7.1
make TARGET=generic
編譯完目錄下有haproxy可執行檔案
將haproxy複製到/usr/local/sbin
cp haproxy /usr/local/sbin
配置檔案
vi config_file
//輸入以下配置
listen rabbitmq_cluster
bind node9:5670
mode tcp
timeout client 3h
timeout server 3h
timeout connect 3h
balance roundrobin
server rabbit6 node6:5672 check inter 5000 rise 2 fall 3
server rabbit7 node7:5672 check inter 5000 rise 2 fall 3
server rabbit8 node8:5672 check inter 5000 rise 2 fall 3
listen private_monitoring
bind node9:8100
mode http
option httplog
timeout client 3h
timeout server 3h
timeout connect 3h
stats enable
stats uri /stats
stats refresh 5s
啟動Haproxy
haproxy -f config_file
Haproxy自帶的配置檔案
haproxy-1.7.1/doc/configuration.txt