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的综合体
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 #实时查看日志内容