采用emq官方网站给的配置示例会有问题。能运行的配置如下
global //全局配置
tune.ssl.default-dh-param 2048
defaults //默认初始配置,listen没有指定情况下使用该值,不然会被listen覆盖
log 127.0.0.1 local3
mode http #所处理的类别 (#7层 http;4层tcp )
maxconn 10000 #最大连接数
option dontlognull #不记录健康检查的日志信息
option redispatch #serverId对应的服务器挂掉后,强制定向到其他健康的服务器
#stats refresh 30 #统计页面刷新间隔
retries 3 #3次连接失败就认为服务不可用,也可以通过后面设置
balance roundrobin #默认的负载均衡的方式,轮询方式
#balance source #默认的负载均衡的方式,类似nginx的ip_hash
#balance leastconn #默认的负载均衡的方式,最小连接
timeout connect 5000 #连接超时
timeout client 50000 #客户端超时
timeout server 50000 #服务器超时
timeout check 2000 #心跳检测超时
listen mqtt-ssl
#bind *:1883
bind *:8883 ssl crt /etc/ssl/emqttd/emq.pem no-sslv3
mode tcp
option clitcpka
maxconn 50000
timeout check 5000
balance leastconn
server emq1 192.168.0.1:1883 check inter 10000 fall 2 rise 5 weight 1
server emq2 192.168.0.2:1883 check inter 10000 fall 2 rise 5 weight 1