套件版本
RabbitMQ 3.6.1
Erlang 18.3
Java JDK 8u91
HaProxy 1.5.14
4台主機
HaProxy 172.20.10.10
MQ_Master 172.20.10.11
MQ_Slave1 172.20.10.12
MQ_Slave2 172.20.10.13
# RabbitMQ Cluster 實作
請參考 RabbitMQ 3.6.1 Cluster 安裝
# HaProxy 安裝
yum install haproxy
# HaProxy 設定
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
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
frontend RabbitmqWeb
bind *:35672
mode http
default_backend RabbitmqCluster:15672
backend RabbitmqCluster:15672
log global
balance roundrobin
cookie SERVERID insert indirect nocache
server mq_master 172.20.10.11:15672 inter 10s check cookie s1
server mq_slave1 172.20.10.12:15672 inter 10s check cookie s2
server mq_slave2 172.20.10.13:15672 inter 10s check cookie s3
listen stats:8888
bind *:8888
mode http
stats enable
stats hide-version
stats realm Haproxy\ Statistics
stats uri /
stats auth admin:haproxy
stats refresh 10s
frontend RabbitmqServer
log global
bind *:45672
mode tcp
option tcplog
option logasap
timeout client 168h
default_backend RabbitmqCluster:5672
backend RabbitmqCluster:5672
mode tcp
timeout server 168h
balance roundrobin
server mq_master 172.20.10.11:5672 check inter 1000 fall 3 rise 3
server mq_slave1 172.20.10.12:5672 check inter 1000 fall 3 rise 3
server mq_slave2 172.20.10.13:5672 check inter 1000 fall 3 rise 3
# 啟動 HaProxy
systemctl start haproxy
systemctl enable haproxy
# HaProxy 介面
172.20.10.10:8888
# RabbitMQ Web 登入介面
172.20.10.10:35672
# RabbitMQ amqp-lib 設定
define('HOST', '172.20.10.10');
define('PORT', 45672);
沒有留言:
張貼留言