EMQ 配置

系统版本: ubuntu 16.04 LTS
EMQ 版本: 2.3.11

我使用的代理就是 EMQ(emqttd) 介绍或者详细的配置可以到官网看看. 我这里只写一些主要的配置.

下载和安装

我从官网下载的是 emqttd-ubuntu16.04-v2.3.11_amd64.deb 下载后直接双击安装即可.

启动

安装后在控制台输出 sudo emqttd console 来启动代理. 启动后会输出如下信息.

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/保存所有配置文件包括插件配置

配置

Erlang 虚拟机主要参数说明

属性名说明
node.process_limitErlang 虚拟机允许的最大进程数,一个 MQTT 连接会消耗2个 Erlang 进程,所以参数值 > 最大连接数 * 2
node.max_portsErlang 虚拟机允许的最大 Port 数量,一个 MQTT 连接消耗1个 Port,所以参数值 > 最大连接数
node.dist_listen_minErlang 分布节点间通信使用 TCP 连接端口范围。注: 节点间如有防火墙,需要配置该端口段
node.dist_listen_maxErlang 分布节点间通信使用 TCP 连接端口范围。注: 节点间如有防火墙,需要配置该端口段

日志参数配置

console 日志
## 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 日志
## Error log file
log.error.file = log/error.log
crash 日志
## Enable the crash log. Enum: on, off
log.crash = on

log.crash.file = log/crash.log
syslog 日志
## Syslog. Enum: on, off
log.syslog = on

##  syslog level. Enum: debug, info, notice, warning, error, critical, alert, emergency
log.syslog.level = error

MQTT 协议参数配置

ClientId 最大允许长度
## Max ClientId Length Allowed.
mqtt.max_clientid_len = 1024
MQTT 最大报文尺寸
## Max Packet Size Allowed, 64K by default.
mqtt.max_packet_size = 64KB
客户端连接闲置时间

设置 MQTT 客户端最大允许闲置时间(Socket 连接建立, 但未收到 CONNECT 报文):

## Client Idle Timeout (Second)
mqtt.client.idle_timeout = 30
启用客户端连接统计
## Enable client Stats: on | off
mqtt.client.enable_stats = off
强制 GC 设置
## Force GC: integer. Value 0 disabled the Force GC.
mqtt.conn.force_gc_count = 100

关于插件的配置参考这里

MQTT 认证设置

EMQ 消息服务器认证由一系列认证插件(Plugin)提供,系统支持按用户名密码、ClientID 或匿名认证.

系统默认开启匿名认证(anonymous),通过加载认证插件可开启的多个认证模块组成认证链:

           ----------------           ----------------           ------------
Client --> | Username认证 | -ignore-> | ClientID认证 | -ignore-> | 匿名认证 |
           ----------------           ----------------           ------------
                  |                         |                         |
                 \|/                       \|/                       \|/
            allow | deny              allow | deny              allow | deny

如果开启 用户名和密码 认证以及 客户ID认证时, 我们会先判断 用户名和密码 如果认证成功会忽略客户端ID, 如果认证失败则会去认证客户端ID.

⚠️ 客户端ID也需要配置密码.
用户名和密码以及客户端ID都是唯一的, 而且连接到代理的会话也是唯一的. 二次连接代理会将前一个下线.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值