erlang物联网开源项目emqtt下载,源码编译,调试工具和图形化监控相关

首页 » 物联网 » erlang物联网开源项目emqtt下载,源码编译,调试工具和图形化监控相关

erlang官方文档,http://erlang.org/doc/man/

emq官网:http://www.emqtt.com/

https://www.emqx.io/

emq简书:https://www.jianshu.com/u/9cbcdf094d33

mqtt调试工具1(不支持websocket):mqtt.fx

http://mqttfx.jensd.de/index.php

http://www.jensd.de/apps/mqttfx/

mqtt调试工具2(不支持websocket):org.eclipse.paho.ui.app,跨平台/全平台,推荐

https://www.eclipse.org/paho/components/tool/

mqtt调试工具3(不支持websocket):qmqtt

https://github.com/emqtt/qmqtt

https://github.com/emqtt/qmqtt-client

https://download.csdn.net/download/libaineu2004/10718381  — firecat本人上传维护的版本

mqtt调试工具4(支持websocket):我们可以使用emq自带的Dashboard插件,进行websocket调试,打开谷歌浏览器输入网址,其中192.168.83.128是emq所在的IP地址:

http://192.168.83.128:18083/#/websocket

用户名:admin,密码:public

WebSocket URI:ws(s)://192.168.83.128:8083/mqtt

TCP URI:tcp://192.168.83.128:1883

mqtt调试工具5(支持websocket):跨平台/全平台,推荐

http://workswithweb.com/mqttbox.html

 

开源项目:

https://github.com/emqx

https://github.com/emqtt

https://github.com/emqx/emqx/tree/1.1.3 — V1

https://github.com/emqx/emqx-rel/tree/v2.3.11 — V2

https://github.com/emqtt/esockd

https://github.com/emqtt/esockd/tree/v4.2

https://github.com/emqtt/gen_logger

https://github.com/emqtt/emqtt_benchmark

https://github.com/mochi/mochiweb

https://github.com/uwiger/gproc

https://github.com/basho/lager

https://github.com/devinus/poolboy

https://github.com/ferd/recon

 

我写的两篇重要的文章推荐,请先看:

centos7环境下的erlang otp的编译

erlang无图形界面的linux下如何使用observer:start().

 

+++++++++++++++v1.1.3++++++++++++++++++++++

https://github.com/emqtt/emqttd

cd emqttd make && make dist 

编译成功后,可执行程序包在目录: rel/emqttd 

控制台启动编译的emqttd程序包: 

cd rel/emqttd && ./bin/emqttd console

./emqttd start

./emqttd stop
./emqttd_ctl cluster join emqttd@172.16.6.161
./emqttd_ctl cluster status
./emqttd_ctl cluster leave
./emqttd_ctl cluster remove emqttd_copy@172.16.6.161

 

图形化监控

在Windows安装erlang OTP,然后在cmd命令提示符输入:
werl -name firecat@172.16.6.??? -setcookie emqttdsecretcookie
或者werl -name firecat@127.0.0.1 -setcookie emqttdsecretcookie
observer:start().
然后shell输入终端命令observer:start().弹出对话框,点击菜单Nodes->Connect Node,输入Linux的节点名称
emqttd@172.16.6.161

emqttd_copy@172.16.6.161

emq1.0和2.0架构变化很大,编译和下载的方式不同了。2.0要求OTP版本在19.1以上,本人使用19.3。

 

++++++++++++++++++++++v2.3.11++++++++++++++++++++

https://github.com/emqx/emqx-rel/tree/v2.3.11,要求erlang OTP 19.3+版本,我们使用OTP19.3即可。

下载解压完成,编译,编译过程会自动去github下载相关的依赖库源码,完整的命令如下:

如果提示/bin/sh: git: command not found,需要安装git
yum install -y git

chmod -R 777 emqx-rel-2.3.11 #获得整个文件夹所有文件的权限

cd emqx-rel-2.3.11 && make

cd _rel/emqttd && ./bin/emqttd console

或者 ./_rel/emqttd/bin/emqttd console

或者 ./_rel/emqttd/bin/emqttd start

        ./_rel/emqttd/bin/emqttd stop

退出进程的方法1:

(emq@192.168.83.128)1> q().
退出进程的方法2:

kill 进程 emq运行之后,在linux后台的进程名称是:beam.smp

 

编译发布插件:

Makefile 增加 

DEPS: DEPS += plugin_name

dep_plugin_name = git url_of_plugin 

relx.config 中 release 段落添加: 

{plugin_name, load},

编译完成之后,/home/firecat/Prj/emq2.0/emqx-rel-2.3.11/data/loaded_plugins设置自启动插件

原始的配置文件的路径是,编译完成每次都会从这里copy一份到_rel

/home/firecat/Prj/emq2.0/emqx-rel-2.3.11/deps/emqttd/etc/emq.conf

/home/firecat/Prj/emq2.0/emqx-rel-2.3.11/data/loaded_plugins

 

starting emqttd on node 'emq@192.168.83.128'
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 V8.3  (abort with ^G)
(emq@192.168.83.128)1> Load emq_mod_presence module successfully.
dashboard:http listen on 0.0.0.0:18083 with 4 acceptors.
http listen on 0.0.0.0:18084 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.

注意:使用XftpPortable软件时,不要用Windows的写字板来编辑emq.conf和loaded_plugins等文件,否则编码不同,会导致emqttd的进程起不来。

 

在Windows操作系统使用图形化监控

在Windows安装erlang OTP,然后在cmd命令提示符输入:
werl -name firecat@127.0.0.1 -setcookie emqsecretcookie

或者werl -name firecat@172.16.6.??? -setcookie emqsecretcookie
observer:start().

然后shell输入终端命令observer:start().弹出对话框,点击菜单Nodes->Connect Node,输入Linux的节点名称

emq@172.16.6.161

 

如果是Linux虚拟机建议使用NAT网络模式,因为Ip地址比较固定,

在物理机Windows终端命令行输入:
werl -name firecat@127.0.0.1 -setcookie emqsecretcookie
或者werl -name firecat@192.168.83.1 -setcookie emqsecretcookie
observer:start().
然后shell输入终端命令observer:start().弹出对话框,点击菜单Nodes->Connect Node,输入Linux的节点名称emq@192.168.83.128

 

emq运行之后,在linux后台的进程名称是:beam.smp

[root@localhost emqx-rel-2.3.11]# netstat -tunlp|egrep "beam.smp"
tcp        0      0 127.0.0.1:11883         0.0.0.0:*               LISTEN      31483/beam.smp      
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      31483/beam.smp      
tcp        0      0 0.0.0.0:8883            0.0.0.0:*               LISTEN      31483/beam.smp      
tcp        0      0 0.0.0.0:8083            0.0.0.0:*               LISTEN      31483/beam.smp      
tcp        0      0 0.0.0.0:8084            0.0.0.0:*               LISTEN      31483/beam.smp      
tcp        0      0 0.0.0.0:1883            0.0.0.0:*               LISTEN      31483/beam.smp      
tcp        4      0 0.0.0.0:6369            0.0.0.0:*               LISTEN      31483/beam.smp      
tcp        0      0 0.0.0.0:18083           0.0.0.0:*               LISTEN      31483/beam.smp      
tcp        0      0 0.0.0.0:18084           0.0.0.0:*               LISTEN      31483/beam.smp      
[root@localhost emqx-rel-2.3.11]# kill -9 31483

 

 

 

常见问题解答:

1、EMQ有kafka插件吗?

答:没,要自己写个,用erlang brod库。https://github.com/klarna/brod

或者erlang ekaf库。https://github.com/helpshift/ekaf

这里有个我自己写的完整kafka项目:

https://blog.csdn.net/libaineu2004/article/details/79542220

参考博客:

(1)https://github.com/msdevanms/emqttd_plugin_kafka_bridge

(2)http://www.cnblogs.com/wunaozai/p/8249657.html

2、EMQ是ejabberd+activemq+rabbitmq的综合体

https://www.ejabberd.im/

https://github.com/TTalkIM

http://www.rabbitmq.com/

http://activemq.apache.org/

3、EMQ的hook和session是参考了ejabberd的。

4、CentOS7默认的防火墙是firewall,关掉它

关闭firewall防火墙:sudo systemctl stop firewalld.service 

关闭firewall开机启动:sudo systemctl disable firewalld.service

firewall-cmd –state #查看状态

5、如果出现域名解析出错

curl#6 – “Could not resolve host: mirrorlist.centos.org; Unknown error”

则修改/etc/resolv.conf,添加

nameserver 8.8.8.8
nameserver 202.106.0.20

6、压缩命令

tar -zcvf emqx-rel-2.3.11.tar.gz emqx-rel-2.3.11

解压命令

tar -xvf emqx-rel-2.3.11.tar.gz

7、erlang打印输出

io:format(“Value is ~p~n”, [Val]).%原生打印

io:format(“Value is ~w~n”, [Val]).%二进制打印

8、emq常用终端命令

./_rel/emqttd/bin/emqttd console
./_rel/emqttd/bin/emqttd start
./_rel/emqttd/bin/emqttd_ctl status
./_rel/emqttd/bin/emqttd stop

./_rel/emqttd/bin/emqttd_ctl cluster join emq@192.168.0.116
./_rel/emqttd/bin/emqttd_ctl cluster status
./_rel/emqttd/bin/emqttd_ctl cluster leave

9、netstat -nalp|grep 1883#查看1883端口的连接情况,观察TCP状态图
netstat -nalp|grep 1883|wc -l #查看1883端口的客户端连接数
ulimit -n 102400 #修改当前进程的最大文件数

10、tail -f *.log #实时查看日志内容

 

本文章来源于互联网,如有侵权,请联系删除!

相关推荐: 2022中国汽车碳中和国际峰会于沪圆满落幕

2022年9月6-7日,由CV International举办的2022中国汽车碳中和国际峰会于上海隆重召开。来自全球的150多位行业领导、专家学者以及杰出企业家代表汇聚一堂,通过专家演讲、主题圆桌、与嘉宾互动等研讨形式,共同探讨汽车碳中和领域的行业焦点、最新…