1.消息队列emqtt

2.x版本之前都叫emqtt,3.x之后版本都叫emqx

下载地址:https://www.emqx.io/cn/downloads#broker


 

安装部署

  1.下载软件包后上传到服务器,解压

1
unzip emqttd-centos7-v2.0.zip

  2.以调试模式启动,检查服务是否正常

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
30
31
32
33
34
35
[root@localhost emqttd]# cd emqttd && ./bin/emqttd console
Exec: /root/emqttd/erts-9.0/bin/erlexec -boot /root/emqttd/releases/2.3.7/emqttd -mode embedded -boot_var ERTS_LIB_DIR /root/emqttd/erts-9.0/../lib -mnesia dir "/root/emqttd/data/mnesia/emq@127.0.0.1" -config /root/emqttd/data/configs/app.2020.05.23.23.38.19.config -args_file /root/emqttd/data/configs/vm.2020.05.23.23.38.19.args -vm_args /root/emqttd/data/configs/vm.2020.05.23.23.38.19.args -- console
Root: /root/emqttd
/root/emqttd
Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:2:2] [ds:2:2: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.7 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.

  3.查看服务启动状态

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

  4.如果服务启动正常,更改为后台启动,启动错误日志将输出到log目录下

1
./bin/emqttd start

  5.EMQ 消息服务器提供了状态监控 URL

1
http://localhost:8080/status

  6.控制台 URL: http://localhost:18083/ ,默认登录用户名: admin, 密码: public。

  7.停止服务器:

1
./bin/emqttd stop

  

调试配置

1.EMQ 2.0 消息服务器默认占用的 TCP 端口包括

1
2
3
4
5
6
7
8
9
10
1883        #MQTT 协议端口
8883        #MQTT/SSL 端口
8083        #MQTT/WebSocket 端口
8084     #MQTT/WebSocket/SSL监听端口
8080        #HTTP API 端口
18083   #Dashboard 管理控制台端口
11883   #MQTT/TCP内部协议监听端口
 
4369     #emq集群通信端口
6369     #erlang集群间通信端口  

2.可通过 etc/emq.conf 配置文件的 ‘listener’ 段落设置(18083是由emq_dashboard插件控制,配置文件在etc/plugins/emq_dashboard.conf)

1
2
3
4
5
6
7
8
9
10
11
## TCP Listener: 1883, 127.0.0.1:1883, ::1:1883
listener.tcp.external = 0.0.0.0:1883
 
## SSL Listener: 8883, 127.0.0.1:8883, ::1:8883
listener.ssl.external = 8883
 
## External MQTT/WebSocket Listener
listener.ws.external = 8083
 
## HTTP Management API Listener
listener.api.mgmt = 127.0.0.1:8080

3.EMQ 消息服务器主要配置文件

1
2
3
etc/emq.conf        #EMQ 2.0 消息服务器配置文件
etc/acl.conf        #EMQ 2.0 默认ACL规则配置文件
etc/plugins/*.conf  #EMQ 2.0 各类插件配置文件  

4.主配置文件

 

分布式集群

  • 默认方式为手动加入集群,配置位于
1
cluster.discovery = manual
  • 以三台机器为例,每台主机更改配置文件中的node.name
1
2
3
4
5
6
7
8
#节点1
node.name = emq@192.168.2.4
 
#节点2
node.name = emq@192.168.2.6
 
#节点3
node.name = emq@192.168.2.100
  • 分别启动三个节点
1
2
#节点1,2,3都是这个命令
./bin/emqttd start
  • 加入集群
1
2
#只需要在其中额外两台节点添加就可以
./bin/emqttd_ctl cluster join emq@192.168.2.100
  • 查看集群节点状态
1
2
3
4
#任意一台都可以查看
./bin/emqttd_ctl cluster status
Cluster status: [{running_nodes,['emq@192.168.2.4','emq@192.168.2.100',
                                 'emq@192.168.2.6']}]
  • 节点退出集群
1
2
3
4
5
#主动离开方式
./bin/emqttd_ctl cluster leave
 
#被动离开方式,被踢出去
./bin/emqttd_ctl cluster remove emq@192.168.1.1

  

上面是手动方式创建的集群,下面在配置文件中规定好集群,改好配置,直接启动就好了

1
2
3
4
5
6
cluster.discovery = static
 
##--------------------------------------------------------------------
## Cluster with static node list
 
cluster.static.seeds = emq1@127.0.0.1,ekka2@127.0.0.1

  

 

  

posted @   ForLivetoLearn  阅读(704)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· DeepSeek在M芯片Mac上本地化部署
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能
历史上的今天:
2018-05-24 jobs后台任务
点击右上角即可分享
微信分享提示