emqttd服务搭建

emqttd服务搭建

1 前言

EMQ X (Erlang/Enterprise/Elastic MQTT Broker) 是基于 Erlang/OTP 平台开发的开源物联网 MQTT 消息服务器。Erlang/OTP 是出色的软实时 (Soft-Realtime)、低延时 (Low-Latency)、分布式 (Distributed) 的语言平台。MQTT 是轻量的 (Lightweight)、发布订阅模式 (PubSub) 的物联网消息协议。

EMQ X 面向海量的 移动 / 物联网 / 车载 等终端接入,并实现在海量物理网设备间快速低延时的消息路由:

  1. 稳定承载大规模的 MQTT 客户端连接,单服务器节点支持百万连接。
  2. 分布式节点集群,快速低延时的消息路由,单集群支持千万规模的路由。
  3. 消息服务器内扩展,支持定制多种认证方式、高效存储消息到后端数据库。
  4. 完整物联网协议支持,MQTT、MQTT-SN、CoAP、LwM2M、私有 TCP/UDP 协议支持。

2 安装和部署

1、从emqx中下载适合自己的稳定版本的emqttd;

2、将下载的压缩包解压;

1
[root@localhost test]# unzip emqttd-centos7-v3.2.3.zip

3、cd进入到emqttd/etc/目录,修改emq.conf的参数,如下几项去掉注释,修改如下:

1
2
3
4
5
6
7
listener.tcp.internal.rate_limit = 100000,10000   //内部连接带宽迸发数 和平均数 (KB)
listener.tcp.external.rate_limit = 100000,10000 //外部连接带宽迸发数 和平均数 (KB)
log.syslog.level = debug //系统日志级别
log.console = file //console 日志指向文件
log.console.size = 10485760 //console 日志文件大小
log.console.count = 10 //console 日志回滚大小
mqtt.allow_anonymous = false //不开启匿名

4、cd进入到emqttd/bin目录下,控制台调试模式启动,检查emqttd是否可正常启动;

1
2
[root@localhost test]# cd emqttd/bin/
[root@localhost bin]# ./emqttd console

启动成功后会有如下打印:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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 3.2.3 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.

5、Ctrl+c关闭控制台,使用守护进程模式启动:

1
2
[root@localhost bin]# ./emqttd start
emqttd 2.3.11 is started successfully!

6、查看运行状态:

1
2
3
[root@localhost bin]# ./emqttd_ctl status
Node 'emq@127.0.0.1' is started
emqttd 3.2.3 is running

7、停止服务器:

1
2
[root@localhost bin]# ./emqttd stop
ok

3 管理

emqttd消息服务器启动后,会默认加载Dashboard插件,启动Web管理控制台。用户可通过Web控制台, 查看服务器运行状态、统计数据、客户端(Client)、会话(Session)、主题(Topic)、订阅(Subscription)。
控制台地址: http://127.0.0.1:18083,默认用户: admin,密码:public (127.0.0.1需要修改为自己本机部署的服务器地址)

更多详细信息:EMQ X 中文文档

EMQ X企业版中文文档

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×