集群部署:
emqtt集群规划三台机器:
10.158.58.111
10.158.58.222
10.158.58.333
1)下载
下载网站:http://emqtt.com/downloads
emqttd-centos7-v2.3.8.zip
2)分别上传到三台后解压安装
unzip emqttd-centos7-v2.3.8.zip
3)EMQ 启动
cd emqttd && ./bin/emqttd console
显示:starting emqttd on node 'emqttd@127.0.0.1'
emqttd ctl is starting...[ok]
emqttd hook is starting...[ok]
emqttd router is starting...[ok]
emqttd pubsub is starting...[ok]
emqttd stats is starting...[ok]
emqttd metrics is starting...[ok]
emqttd pooler is starting...[ok]
emqttd trace is starting...[ok]
emqttd client manager is starting...[ok]
emqttd session manager is starting...[ok]
emqttd session supervisor is starting...[ok]
emqttd wsclient supervisor is starting...[ok]
emqttd broker is starting...[ok]
emqttd alarm is starting...[ok]
emqttd mod supervisor is starting...[ok]
emqttd bridge supervisor is starting...[ok]
emqttd access control is starting...[ok]
说明成功;
4)守护进程模式启动
./bin/emqttd start
emqttd 2.3.8 is started successfully!
说明启动成功
基于 static 节点列表自动集群:
5)修改配置文件:emqttd/etc/emq.conf
node.name = emq@IP(本机)
cluster.discovery = static
## Cluster with static node list
cluster.static.seeds = emq1@10.158.58.111,emq1@10.158.58.222,emq1@10.158.58.333
## TCP Listener
listener.tcp.external = 0.0.0.0:1883
listener.tcp.external.acceptors = 64
listener.tcp.external.max_clients = 1000000
## Erlang Process Limit
node.process_limit = 2097152
## Sets the maximum number of simultaneously existing ports for this system
node.max_ports = 1048576
6) 分别启动emqtt查看集群;
任意节点上查询集群状态:
$ ./bin/emqttd_ctl cluster status
Clusterstatus:[{running_nodes,[emq1@10.158.58.111,emq1@10.158.58.222,emq1@10.158.58.333}]
说明健康;
集群的优化配置:修改/etc/sysctl.conf
fs.file-max = 2097152
fs.nr_open = 2097152
net.core.somaxconn = 32768
net.ipv4.tcp_max_syn_backlog = 16384
net.core.netdev_max_backlog = 16384
net.ipv4.ip_local_port_range = 1000 65535
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.optmem_max = 16777216
net.ipv4.tcp_rmem = 1024 4096 16777216
net.ipv4.tcp_wmem = 1024 4096 16777216
net.nf_conntrack_max = 1000000
net.netfilter.nf_conntrack_max = 1000000
net.ipv4.tcp_max_tw_buckets = 1048576
net.ipv4.tcp_fin_timeout = 15
修改:/etc/systemd/system.conf
DefaultLimitNOFILE=1048576
修改:/etc/security/limits.conf
* soft nofile 1048576
* hard nofile 1048576