CentOS 7 搭建mqtt服务——筑梦之路

服务器


安装Emqx服务器

安装必要的依赖:
$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2

设置稳定的仓库,比如CentOs7的例子:
$sudo yum-config-manager --add-repo https://repos.emqx.io/emqx-ce/redhat/centos/7/emqx-ce.repo

安装最新版本的 EMQ X
$ sudo yum install emqx

也可以安装指定版本
先查询软件版本列表
$ yum list emqx --showduplicates | sort -r

emqx.x86_64                     3.1.0-1.el7                        emqx-stable
emqx.x86_64                     3.0.1-1.el7                        emqx-stable
emqx.x86_64                     3.0.0-1.el7                        emqx-stable

选择其中一个版本安装

$ sudo yum install emqx-3.1.0

启动Emqx

直接启动
$ emqx start
 emqx 3.1.0 is started successfully!

$ emqx_ctl status
 Node '[email protected]' is started
 emqx v3.1.0 is running
 
系统启动
$ sudo systemctl start emqx

服务启动
$ sudo service emqx start```

开放端口

阿里云实例安全组和防火墙开放端口

端口    端口对应的协议或者作用
1883    MQTT protocol port
8883    MQTT/SSL port
8083    MQTT/WebSocket port
8080    HTTP API port
18083   Dashboard Management Console Port

firewall-cmd --zone=public --add-port=XXXXX/tcp --permanent   # 开放XXXXX端口

firewall-cmd  --permanent --zone=public --list-ports   #查看防火墙开放了哪些端口

firewall-cmd --state  #查看防火墙状态

firewall-cmd --reload   # 配置立即生效


访问Emqx服务后台

访问后台地址:http://localhost:18083,其中localhost可以替换为你服务器公网IP或者虚拟机IP。
登录账号:admin,密码:public。进入Web管理控制台。


测试Emqx 服务是否可用

第一种方法 下载客户端

下载客户端工具:MQTTBox
地址:http://workswithweb.com/html/mqttbox/downloads.html

猜你喜欢

转载自blog.csdn.net/qq_34777982/article/details/126911413