系统版本: ubuntu 16.04 LTS
EMQ 版本: 2.3.11
我使用的代理就是 EMQ(emqttd) 介绍或者详细的配置能够到官网看看. 我这里只写一些主要的配置.html
我从官网下载的是 emqttd-ubuntu16.04-v2.3.11_amd64.deb
下载后直接双击安装便可.node
安装后在控制台输出 sudo emqttd console
来启动代理. 启动后会输出以下信息.shell
Exec: /usr/lib/emqttd/erts-9.0/bin/erlexec -boot /usr/lib/emqttd/releases/2.3.11/emqttd -mode embedded -boot_var ERTS_LIB_DIR /usr/lib/emqttd/erts-9.0/../lib -mnesia dir "/var/lib/emqttd/mnesia/emq@127.0.0.1" -config /var/lib/emqttd/configs/app.2018.10.03.18.37.02.config -args_file /var/lib/emqttd/configs/vm.2018.10.03.18.37.02.args -vm_args /var/lib/emqttd/configs/vm.2018.10.03.18.37.02.args -- console Root: /usr/lib/emqttd /usr/lib/emqttd Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:32] [hipe] [kernel-poll:true] starting emqttd on node 'emq@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] emqttd system monitor is starting...[ok] emqttd 2.3.11 is running now Eshell V9.0 (abort with ^G) (emq@127.0.0.1)1> Load emq_mod_presence module successfully. dashboard:http listen on 0.0.0.0:18083 with 4 acceptors. mqtt:tcp listen on 127.0.0.1:11883 with 4 acceptors. mqtt:tcp listen on 0.0.0.0:1883 with 16 acceptors. mqtt:ws listen on 0.0.0.0:8083 with 4 acceptors. mqtt:ssl listen on 0.0.0.0:8883 with 16 acceptors. mqtt:wss listen on 0.0.0.0:8084 with 4 acceptors. mqtt:api listen on 0.0.0.0:8080 with 4 acceptors.
也能够用这两个命令来启停
systemctl start emqttd
systemctl stop emqttd
目录 | 说明 |
---|---|
/usr/lib/emqttd/ | 全部的可执行文件包括插件 |
/etc/emqttd/ | 保存全部配置文件包括插件配置 |
属性名 | 说明 |
---|---|
node.process_limit | Erlang 虚拟机容许的最大进程数,一个 MQTT 链接会消耗2个 Erlang 进程,因此参数值 > 最大链接数 * 2 |
node.max_ports | Erlang 虚拟机容许的最大 Port 数量,一个 MQTT 链接消耗1个 Port,因此参数值 > 最大链接数 |
node.dist_listen_min | Erlang 分布节点间通讯使用 TCP 链接端口范围。注: 节点间若有防火墙,须要配置该端口段 |
node.dist_listen_max | Erlang 分布节点间通讯使用 TCP 链接端口范围。注: 节点间若有防火墙,须要配置该端口段 |
## Console log. Enum: off, file, console, both log.console = console ## Console log level. Enum: debug, info, notice, warning, error, critical, alert, emergency log.console.level = error ## Console log file ## log.console.file = log/console.log
## Error log file log.error.file = log/error.log
## Enable the crash log. Enum: on, off log.crash = on log.crash.file = log/crash.log
## Syslog. Enum: on, off log.syslog = on ## syslog level. Enum: debug, info, notice, warning, error, critical, alert, emergency log.syslog.level = error
## Max ClientId Length Allowed. mqtt.max_clientid_len = 1024
## Max Packet Size Allowed, 64K by default. mqtt.max_packet_size = 64KB
设置 MQTT 客户端最大容许闲置时间(Socket 链接创建, 但未收到 CONNECT 报文):ubuntu
## Client Idle Timeout (Second) mqtt.client.idle_timeout = 30
## Enable client Stats: on | off mqtt.client.enable_stats = off
## Force GC: integer. Value 0 disabled the Force GC. mqtt.conn.force_gc_count = 100
关于插件的配置参考这里api
EMQ 消息服务器认证由一系列认证插件(Plugin)提供,系统支持按用户名密码、ClientID 或匿名认证.服务器
系统默认开启匿名认证(anonymous),经过加载认证插件可开启的多个认证模块组成认证链:session
---------------- ---------------- ------------ Client --> | Username认证 | -ignore-> | ClientID认证 | -ignore-> | 匿名认证 | ---------------- ---------------- ------------ | | | \|/ \|/ \|/ allow | deny allow | deny allow | deny
若是开启 用户名和密码 认证以及 客户ID认证时, 咱们会先判断 用户名和密码 若是认证成功会忽略客户端ID, 若是认证失败则会去认证客户端ID.app
⚠️ 客户端ID也须要配置密码. 用户名和密码以及客户端ID都是惟一的, 并且链接到代理的会话也是惟一的. 二次链接代理会将前一个下线.