emqx集群部分配置参考:emqx静态集群_白泽的博客-CSDN博客
本文着重记录HAPorxy搭建。
安装:
sudo apt-get update
sudo apt-get install software-properties-common -y
sudo add-apt-repository -y ppa:vbernat/haproxy-2.2
sudo apt-get update
sudo apt-get install -y haproxy=2.2.\*
- 配置 /etc/haproxy/haproxy.cfg,末尾增加:
listen mqtt-ssl
bind *:8883 ssl crt /etc/ssl/emqx/emq.pem no-sslv3
#bind *:1883 #不使用ssl可用这个配置
mode tcp
maxconn 50000
timeout client 600s
default_backend emqx_cluster
backend emqx_cluster
mode tcp
balance source
timeout server 50s
timeout check 5000
server emqx1 192.168.0.2:1883 check inter 10000 fall 2 rise 5 weight 1 #emqx1为自定义名称
server emqx2 192.168.0.3:1883 check inter 10000 fall 2 rise 5 weight 1
?启动haproxy:
sudo service haproxy start
停止haproxy:
sudo service haproxy stop
|