自己在Vmware中搭建mqtt服务器

news2024/11/28 13:38:03

前言

在学习某个HMI的使用的时候,这个HMI带有MQTT功能,就想着自己是不是能够搭建一个自己的MQTT的服务器呢?

一、mqtt 自己搭建之一:Mosquitto

自己搭建MQTT服务器需要安装和运行MQTT服务软件,比如常用的是Mosquitto。以下是在Linux系统上搭建Mosquitto的简要步骤:

1.安装Mosquitto:

sudo apt-update

sudo apt-get install mosquitto

2.启动Mosquitto服务

sudo systemctl start mosquitto

3.使Mosquitto随系统启动:

sudo systemctl enable mosquitto

(可选)配置Mosquitto的配置文件 /etc/mosquitto/mosquitto.conf 来调整设置,如设置密码,配置监听端口等。

(可选)如果需要用户认证,创建一个密码文件:

sudo mosquitto_passwd -c /etc/mosquitto/passwd.conf username

在Mosquitto的配置文件中启用用户认证并指定密码文件:

allow_anonymous false

password_file /etc/mosquitto/passwd.conf

重启Mosquitto以应用新的配置:

sudo systemctl restart mosquitto

这样就完成了基本的Mosquitto服务器搭建。可以用任何MQTT客户端连接到服务器进行测试。

提示:AI自动生成,仅供参考

然后使用MQTT.fx进行连接测试。。。失败。无法连接。

二、mqtt 自己搭建之二:emqx

2.1.下载

Download EMQX Open Source “https://www.emqx.com/en/downloads-and-install/broker?os=RHEL”

2.2安装

2.2.1 Download the EMQX repository

curl -s https://assets.emqx.com/scripts/install-emqx-rpm.sh | sudo bash

2.2.2 Install the dependencies

yum install epel-release -y

yum install -y openssl11 openssl11-devel

2.2.3 Install EMQX

sudo yum install emqx -y

2.2.4 Run EMQX

sudo systemctl start emqx

Documentation →

2.2.5 实际操作

2.2.5.1 Download the EMQX repository

[root@localhost ~]# curl -s https://assets.emqx.com/scripts/install-emqx-rpm.sh | sudo bash

Detected operating system as centos/7.

Checking for curl...

Detected curl...

Downloading repository file: https://packages.emqx.com/install/repositories/emqx/emqx/config_file.repo?os=centos&dist=7&source=script

done.

Installing pygpgme to verify GPG signatures...

已加载插件:fastestmirror

Loading mirror speeds from cached hostfile

epel/x86_64/metalink                                                                                                |  16 kB  00:00:00     

 * base: mirrors.aliyun.com

 * epel: hkg.mirror.rackspace.com

 * extras: mirrors.aliyun.com

 * updates: mirrors.aliyun.com

base                                                                                                                | 3.6 kB  00:00:00     

emqx_emqx-source/signature                                                                                          |  833 B  00:00:00     

从 https://packages.emqx.com/emqx/emqx/gpgkey 检索密钥

导入 GPG key 0x209FFEEA:

 用户ID     : "https://packagecloud.io/emqx/emqx (https://packagecloud.io/docs#gpg_signing) <support@packagecloud.io>"

 指纹       : 68f8 af1b 1028 7ade 8ae7 fdec 0140 2cc4 209f feea

 来自       : https://packages.emqx.com/emqx/emqx/gpgkey

emqx_emqx-source/signature                                                                                          | 1.7 kB  00:00:01 !!!

extras                                                                                                              | 2.9 kB  00:00:00     

updates                                                                                                             | 2.9 kB  00:00:00     

emqx_emqx-source/primary                                                                                            |  175 B  00:00:01     

软件包 pygpgme-0.3-9.el7.x86_64 已安装并且是最新版本

无须任何处理

Installing yum-utils...

已加载插件:fastestmirror

Loading mirror speeds from cached hostfile

 * base: mirrors.aliyun.com

 * epel: mirror.01link.hk

 * extras: mirrors.aliyun.com

 * updates: mirrors.aliyun.com

正在解决依赖关系

--> 正在检查事务

---> 软件包 yum-utils.noarch.0.1.1.31-54.el7_8 将被 安装

--> 正在处理依赖关系 python-kitchen,它被软件包 yum-utils-1.1.31-54.el7_8.noarch 需要

--> 正在处理依赖关系 libxml2-python,它被软件包 yum-utils-1.1.31-54.el7_8.noarch 需要

--> 正在检查事务

---> 软件包 libxml2-python.x86_64.0.2.9.1-6.el7_9.6 将被 安装

--> 正在处理依赖关系 libxml2 = 2.9.1-6.el7_9.6,它被软件包 libxml2-python-2.9.1-6.el7_9.6.x86_64 需要

---> 软件包 python-kitchen.noarch.0.1.1.1-5.el7 将被 安装

--> 正在处理依赖关系 python-chardet,它被软件包 python-kitchen-1.1.1-5.el7.noarch 需要

--> 正在检查事务

---> 软件包 libxml2.x86_64.0.2.9.1-6.el7.5 将被 升级

---> 软件包 libxml2.x86_64.0.2.9.1-6.el7_9.6 将被 更新

---> 软件包 python-chardet.noarch.0.2.2.1-3.el7 将被 安装

--> 解决依赖关系完成

依赖关系解决

===========================================================================================================================================

 Package                             架构                        版本                                   源                            大小

===========================================================================================================================================

正在安装:

 yum-utils                           noarch                      1.1.31-54.el7_8                        base                         122 k

为依赖而安装:

 libxml2-python                      x86_64                      2.9.1-6.el7_9.6                        updates                      247 k

 python-chardet                      noarch                      2.2.1-3.el7                            base                         227 k

 python-kitchen                      noarch                      1.1.1-5.el7                            base                         267 k

为依赖而更新:

 libxml2                             x86_64                      2.9.1-6.el7_9.6                        updates                      668 k

事务概要

===========================================================================================================================================

安装  1 软件包 (+3 依赖软件包)

升级           ( 1 依赖软件包)

总下载量:1.5 M

Downloading packages:

Delta RPMs disabled because /usr/bin/applydeltarpm not installed.

(1/5): libxml2-python-2.9.1-6.el7_9.6.x86_64.rpm                                                                    | 247 kB  00:00:00     

(2/5): libxml2-2.9.1-6.el7_9.6.x86_64.rpm                                                                           | 668 kB  00:00:00     

(3/5): python-chardet-2.2.1-3.el7.noarch.rpm                                                                        | 227 kB  00:00:00     

(4/5): python-kitchen-1.1.1-5.el7.noarch.rpm                                                                        | 267 kB  00:00:00     

(5/5): yum-utils-1.1.31-54.el7_8.noarch.rpm                                                                         | 122 kB  00:00:00     

-------------------------------------------------------------------------------------------------------------------------------------------

总计                                                                                                       1.8 MB/s | 1.5 MB  00:00:00     

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  正在更新    : libxml2-2.9.1-6.el7_9.6.x86_64                                                                                         1/6

  正在安装    : libxml2-python-2.9.1-6.el7_9.6.x86_64                                                                                  2/6

  正在安装    : python-chardet-2.2.1-3.el7.noarch                                                                                      3/6

  正在安装    : python-kitchen-1.1.1-5.el7.noarch                                                                                      4/6

  正在安装    : yum-utils-1.1.31-54.el7_8.noarch                                                                                       5/6

  清理        : libxml2-2.9.1-6.el7.5.x86_64                                                                                           6/6

  验证中      : python-chardet-2.2.1-3.el7.noarch                                                                                      1/6

  验证中      : libxml2-2.9.1-6.el7_9.6.x86_64                                                                                         2/6

  验证中      : libxml2-python-2.9.1-6.el7_9.6.x86_64                                                                                  3/6

  验证中      : python-kitchen-1.1.1-5.el7.noarch                                                                                      4/6

  验证中      : yum-utils-1.1.31-54.el7_8.noarch                                                                                       5/6

  验证中      : libxml2-2.9.1-6.el7.5.x86_64                                                                                           6/6

已安装:

  yum-utils.noarch 0:1.1.31-54.el7_8                                                                                                       

作为依赖被安装:

  libxml2-python.x86_64 0:2.9.1-6.el7_9.6         python-chardet.noarch 0:2.2.1-3.el7         python-kitchen.noarch 0:1.1.1-5.el7        

作为依赖被升级:

  libxml2.x86_64 0:2.9.1-6.el7_9.6                                                                                                         

完毕!

Generating yum cache for emqx_emqx...

导入 GPG key 0x209FFEEA:

 用户ID     : "https://packagecloud.io/emqx/emqx (https://packagecloud.io/docs#gpg_signing) <support@packagecloud.io>"

 指纹       : 68f8 af1b 1028 7ade 8ae7 fdec 0140 2cc4 209f feea

 来自       : https://packages.emqx.com/emqx/emqx/gpgkey

Generating yum cache for emqx_emqx-source...

The repository is setup! You can now install packages.

2.2.5.1 Install the dependencies
a)第一步

[root@localhost ~]# yum install epel-release -y

已加载插件:fastestmirror

Loading mirror speeds from cached hostfile

 * base: mirrors.aliyun.com

 * epel: mirror.nyist.edu.cn

 * extras: mirrors.aliyun.com

 * updates: mirrors.aliyun.com

正在解决依赖关系

--> 正在检查事务

---> 软件包 epel-release.noarch.0.7-11 将被 升级

---> 软件包 epel-release.noarch.0.7-14 将被 更新

--> 解决依赖关系完成

依赖关系解决

===========================================================================================================================================

 Package                               架构                            版本                            源                             大小

===========================================================================================================================================

正在更新:

 epel-release                          noarch                          7-14                            epel                           15 k

事务概要

===========================================================================================================================================

升级  1 软件包

总下载量:15 k

Downloading packages:

Delta RPMs disabled because /usr/bin/applydeltarpm not installed.

epel-release-7-14.noarch.rpm                                                                                        |  15 kB  00:00:00     

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  正在更新    : epel-release-7-14.noarch                                                                                               1/2

  清理        : epel-release-7-11.noarch                                                                                               2/2

  验证中      : epel-release-7-14.noarch                                                                                               1/2

  验证中      : epel-release-7-11.noarch                                                                                               2/2

更新完毕:

  epel-release.noarch 0:7-14                                                                                                               

完毕!

b)第二步

[root@localhost ~]# yum install -y openssl11 openssl11-devel

已加载插件:fastestmirror

Loading mirror speeds from cached hostfile

 * base: mirrors.aliyun.com

 * epel: mirrors.aliyun.com

 * extras: mirrors.aliyun.com

 * updates: mirrors.aliyun.com

正在解决依赖关系

--> 正在检查事务

---> 软件包 openssl11.x86_64.1.1.1.1k-7.el7 将被 安装

--> 正在处理依赖关系 openssl11-libs(x86-64) = 1:1.1.1k-7.el7,它被软件包 1:openssl11-1.1.1k-7.el7.x86_64 需要

--> 正在处理依赖关系 libcrypto.so.1.1(OPENSSL_1_1_0)(64bit),它被软件包 1:openssl11-1.1.1k-7.el7.x86_64 需要

--> 正在处理依赖关系 libcrypto.so.1.1(OPENSSL_1_1_1)(64bit),它被软件包 1:openssl11-1.1.1k-7.el7.x86_64 需要

--> 正在处理依赖关系 libssl.so.1.1(OPENSSL_1_1_0)(64bit),它被软件包 1:openssl11-1.1.1k-7.el7.x86_64 需要

--> 正在处理依赖关系 libssl.so.1.1(OPENSSL_1_1_1)(64bit),它被软件包 1:openssl11-1.1.1k-7.el7.x86_64 需要

--> 正在处理依赖关系 libcrypto.so.1.1()(64bit),它被软件包 1:openssl11-1.1.1k-7.el7.x86_64 需要

--> 正在处理依赖关系 libssl.so.1.1()(64bit),它被软件包 1:openssl11-1.1.1k-7.el7.x86_64 需要

---> 软件包 openssl11-devel.x86_64.1.1.1.1k-7.el7 将被 安装

--> 正在处理依赖关系 krb5-devel(x86-64),它被软件包 1:openssl11-devel-1.1.1k-7.el7.x86_64 需要

--> 正在处理依赖关系 zlib-devel(x86-64),它被软件包 1:openssl11-devel-1.1.1k-7.el7.x86_64 需要

--> 正在检查事务

---> 软件包 krb5-devel.x86_64.0.1.15.1-55.el7_9 将被 安装

--> 正在处理依赖关系 libkadm5(x86-64) = 1.15.1-55.el7_9,它被软件包 krb5-devel-1.15.1-55.el7_9.x86_64 需要

--> 正在处理依赖关系 krb5-libs(x86-64) = 1.15.1-55.el7_9,它被软件包 krb5-devel-1.15.1-55.el7_9.x86_64 需要

--> 正在处理依赖关系 libverto-devel,它被软件包 krb5-devel-1.15.1-55.el7_9.x86_64 需要

--> 正在处理依赖关系 libselinux-devel,它被软件包 krb5-devel-1.15.1-55.el7_9.x86_64 需要

--> 正在处理依赖关系 libcom_err-devel,它被软件包 krb5-devel-1.15.1-55.el7_9.x86_64 需要

--> 正在处理依赖关系 keyutils-libs-devel,它被软件包 krb5-devel-1.15.1-55.el7_9.x86_64 需要

---> 软件包 openssl11-libs.x86_64.1.1.1.1k-7.el7 将被 安装

---> 软件包 zlib-devel.x86_64.0.1.2.7-21.el7_9 将被 安装

--> 正在处理依赖关系 zlib = 1.2.7-21.el7_9,它被软件包 zlib-devel-1.2.7-21.el7_9.x86_64 需要

--> 正在检查事务

---> 软件包 keyutils-libs-devel.x86_64.0.1.5.8-3.el7 将被 安装

---> 软件包 krb5-libs.x86_64.0.1.15.1-50.el7 将被 升级

---> 软件包 krb5-libs.x86_64.0.1.15.1-55.el7_9 将被 更新

---> 软件包 libcom_err-devel.x86_64.0.1.42.9-19.el7 将被 安装

---> 软件包 libkadm5.x86_64.0.1.15.1-55.el7_9 将被 安装

---> 软件包 libselinux-devel.x86_64.0.2.5-15.el7 将被 安装

--> 正在处理依赖关系 libsepol-devel(x86-64) >= 2.5-10,它被软件包 libselinux-devel-2.5-15.el7.x86_64 需要

--> 正在处理依赖关系 pkgconfig(libsepol),它被软件包 libselinux-devel-2.5-15.el7.x86_64 需要

--> 正在处理依赖关系 pkgconfig(libpcre),它被软件包 libselinux-devel-2.5-15.el7.x86_64 需要

---> 软件包 libverto-devel.x86_64.0.0.2.5-4.el7 将被 安装

---> 软件包 zlib.x86_64.0.1.2.7-18.el7 将被 升级

---> 软件包 zlib.x86_64.0.1.2.7-21.el7_9 将被 更新

--> 正在检查事务

---> 软件包 libsepol-devel.x86_64.0.2.5-10.el7 将被 安装

---> 软件包 pcre-devel.x86_64.0.8.32-17.el7 将被 安装

--> 解决依赖关系完成

依赖关系解决

===========================================================================================================================================

 Package                                 架构                       版本                                 源                           大小

===========================================================================================================================================

正在安装:

 openssl11                               x86_64                     1:1.1.1k-7.el7                       epel                        694 k

 openssl11-devel                         x86_64                     1:1.1.1k-7.el7                       epel                        2.3 M

为依赖而安装:

 keyutils-libs-devel                     x86_64                     1.5.8-3.el7                          base                         37 k

 krb5-devel                              x86_64                     1.15.1-55.el7_9                      updates                     273 k

 libcom_err-devel                        x86_64                     1.42.9-19.el7                        base                         32 k

 libkadm5                                x86_64                     1.15.1-55.el7_9                      updates                     180 k

 libselinux-devel                        x86_64                     2.5-15.el7                           base                        187 k

 libsepol-devel                          x86_64                     2.5-10.el7                           base                         77 k

 libverto-devel                          x86_64                     0.2.5-4.el7                          base                         12 k

 openssl11-libs                          x86_64                     1:1.1.1k-7.el7                       epel                        1.5 M

 pcre-devel                              x86_64                     8.32-17.el7                          base                        480 k

 zlib-devel                              x86_64                     1.2.7-21.el7_9                       updates                      50 k

为依赖而更新:

 krb5-libs                               x86_64                     1.15.1-55.el7_9                      updates                     810 k

 zlib                                    x86_64                     1.2.7-21.el7_9                       updates                      90 k

事务概要

===========================================================================================================================================

安装  2 软件包 (+10 依赖软件包)

升级           (  2 依赖软件包)

总下载量:6.7 M

Downloading packages:

Delta RPMs disabled because /usr/bin/applydeltarpm not installed.

(1/14): keyutils-libs-devel-1.5.8-3.el7.x86_64.rpm                                                                  |  37 kB  00:00:00     

(2/14): libcom_err-devel-1.42.9-19.el7.x86_64.rpm                                                                   |  32 kB  00:00:00     

(3/14): krb5-devel-1.15.1-55.el7_9.x86_64.rpm                                                                       | 273 kB  00:00:00     

(4/14): krb5-libs-1.15.1-55.el7_9.x86_64.rpm                                                                        | 810 kB  00:00:00     

(5/14): libkadm5-1.15.1-55.el7_9.x86_64.rpm                                                                         | 180 kB  00:00:00     

(6/14): libselinux-devel-2.5-15.el7.x86_64.rpm                                                                      | 187 kB  00:00:00     

(7/14): libverto-devel-0.2.5-4.el7.x86_64.rpm                                                                       |  12 kB  00:00:00     

(8/14): libsepol-devel-2.5-10.el7.x86_64.rpm                                                                        |  77 kB  00:00:00     

(9/14): openssl11-1.1.1k-7.el7.x86_64.rpm                                                                           | 694 kB  00:00:00     

(10/14): openssl11-devel-1.1.1k-7.el7.x86_64.rpm                                                                    | 2.3 MB  00:00:01     

(11/14): zlib-1.2.7-21.el7_9.x86_64.rpm                                                                             |  90 kB  00:00:00     

(12/14): openssl11-libs-1.1.1k-7.el7.x86_64.rpm                                                                     | 1.5 MB  00:00:00     

(13/14): pcre-devel-8.32-17.el7.x86_64.rpm                                                                          | 480 kB  00:00:00     

(14/14): zlib-devel-1.2.7-21.el7_9.x86_64.rpm                                                                       |  50 kB  00:00:00     

-------------------------------------------------------------------------------------------------------------------------------------------

总计                                                                                                       2.3 MB/s | 6.7 MB  00:00:02     

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  正在更新    : zlib-1.2.7-21.el7_9.x86_64                                                                                            1/16

  正在安装    : 1:openssl11-libs-1.1.1k-7.el7.x86_64                                                                                  2/16

  正在更新    : krb5-libs-1.15.1-55.el7_9.x86_64                                                                                      3/16

  正在安装    : libkadm5-1.15.1-55.el7_9.x86_64                                                                                       4/16

  正在安装    : zlib-devel-1.2.7-21.el7_9.x86_64                                                                                      5/16

  正在安装    : keyutils-libs-devel-1.5.8-3.el7.x86_64                                                                                6/16

  正在安装    : pcre-devel-8.32-17.el7.x86_64                                                                                         7/16

  正在安装    : libverto-devel-0.2.5-4.el7.x86_64                                                                                     8/16

  正在安装    : libcom_err-devel-1.42.9-19.el7.x86_64                                                                                 9/16

  正在安装    : libsepol-devel-2.5-10.el7.x86_64                                                                                     10/16

  正在安装    : libselinux-devel-2.5-15.el7.x86_64                                                                                   11/16

  正在安装    : krb5-devel-1.15.1-55.el7_9.x86_64                                                                                    12/16

  正在安装    : 1:openssl11-devel-1.1.1k-7.el7.x86_64                                                                                13/16

  正在安装    : 1:openssl11-1.1.1k-7.el7.x86_64                                                                                      14/16

  清理        : zlib-1.2.7-18.el7.x86_64                                                                                             15/16

  清理        : krb5-libs-1.15.1-50.el7.x86_64                                                                                       16/16

  验证中      : libsepol-devel-2.5-10.el7.x86_64                                                                                      1/16

  验证中      : libselinux-devel-2.5-15.el7.x86_64                                                                                    2/16

  验证中      : libcom_err-devel-1.42.9-19.el7.x86_64                                                                                 3/16

  验证中      : libverto-devel-0.2.5-4.el7.x86_64                                                                                     4/16

  验证中      : libkadm5-1.15.1-55.el7_9.x86_64                                                                                       5/16

  验证中      : krb5-libs-1.15.1-55.el7_9.x86_64                                                                                      6/16

  验证中      : krb5-devel-1.15.1-55.el7_9.x86_64                                                                                     7/16

  验证中      : pcre-devel-8.32-17.el7.x86_64                                                                                         8/16

  验证中      : 1:openssl11-devel-1.1.1k-7.el7.x86_64                                                                                 9/16

  验证中      : 1:openssl11-libs-1.1.1k-7.el7.x86_64                                                                                 10/16

  验证中      : 1:openssl11-1.1.1k-7.el7.x86_64                                                                                      11/16

  验证中      : zlib-devel-1.2.7-21.el7_9.x86_64                                                                                     12/16

  验证中      : zlib-1.2.7-21.el7_9.x86_64                                                                                           13/16

  验证中      : keyutils-libs-devel-1.5.8-3.el7.x86_64                                                                               14/16

  验证中      : zlib-1.2.7-18.el7.x86_64                                                                                             15/16

  验证中      : krb5-libs-1.15.1-50.el7.x86_64                                                                                       16/16

已安装:

  openssl11.x86_64 1:1.1.1k-7.el7                                   openssl11-devel.x86_64 1:1.1.1k-7.el7                                  

作为依赖被安装:

  keyutils-libs-devel.x86_64 0:1.5.8-3.el7       krb5-devel.x86_64 0:1.15.1-55.el7_9        libcom_err-devel.x86_64 0:1.42.9-19.el7      

  libkadm5.x86_64 0:1.15.1-55.el7_9              libselinux-devel.x86_64 0:2.5-15.el7       libsepol-devel.x86_64 0:2.5-10.el7           

  libverto-devel.x86_64 0:0.2.5-4.el7            openssl11-libs.x86_64 1:1.1.1k-7.el7       pcre-devel.x86_64 0:8.32-17.el7              

  zlib-devel.x86_64 0:1.2.7-21.el7_9            

作为依赖被升级:

  krb5-libs.x86_64 0:1.15.1-55.el7_9                                      zlib.x86_64 0:1.2.7-21.el7_9                                     

完毕!

2.2.5.3 Install EMQX

[root@localhost ~]# sudo yum install emqx -y

已加载插件:fastestmirror

Loading mirror speeds from cached hostfile

 * base: mirrors.aliyun.com

 * epel: mirrors.aliyun.com

 * extras: mirrors.aliyun.com

 * updates: mirrors.aliyun.com

正在解决依赖关系

--> 正在检查事务

---> 软件包 emqx.x86_64.0.5.7.1-1.el7 将被 安装

--> 正在处理依赖关系 libatomic,它被软件包 emqx-5.7.1-1.el7.x86_64 需要

--> 正在检查事务

---> 软件包 libatomic.x86_64.0.4.8.5-44.el7 将被 安装

--> 解决依赖关系完成

依赖关系解决

===========================================================================================================================================

 Package                          架构                          版本                                源                                大小

===========================================================================================================================================

正在安装:

 emqx                             x86_64                        5.7.1-1.el7                         emqx_emqx                         59 M

为依赖而安装:

 libatomic                        x86_64                        4.8.5-44.el7                        base                              51 k

事务概要

===========================================================================================================================================

安装  1 软件包 (+1 依赖软件包)

总下载量:59 M

安装大小:146 M

Downloading packages:

(1/2): libatomic-4.8.5-44.el7.x86_64.rpm                                                                            |  51 kB  00:00:00     

(2/2): emqx-5.7.1-1.el7.x86_64.rpm                                                                                  |  59 MB  00:03:55     

-------------------------------------------------------------------------------------------------------------------------------------------

总计                                                                                                       255 kB/s |  59 MB  00:03:55     

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  正在安装    : libatomic-4.8.5-44.el7.x86_64                                                                                          1/2

  正在安装    : emqx-5.7.1-1.el7.x86_64                                                                                                2/2

Created symlink from /etc/systemd/system/multi-user.target.wants/emqx.service to /usr/lib/systemd/system/emqx.service.

  验证中      : libatomic-4.8.5-44.el7.x86_64                                                                                          1/2

  验证中      : emqx-5.7.1-1.el7.x86_64                                                                                                2/2

已安装:

  emqx.x86_64 0:5.7.1-1.el7                                                                                                                

作为依赖被安装:

  libatomic.x86_64 0:4.8.5-44.el7                                                                                                          

完毕!

2.2.5.4 Run EMQX

[root@localhost ~]# sudo systemctl start emqx

[root@localhost ~]# sudo systemctl stop mosquitto

[root@localhost ~]#

[root@localhost ~]# systemctl status emqx

● emqx.service - emqx daemon

   Loaded: loaded (/usr/lib/systemd/system/emqx.service; enabled; vendor preset: disabled)

   Active: active (running) since 日 2024-07-28 19:22:55 CST; 1min 54s ago

 Main PID: 1128 (beam.smp)

   CGroup: /system.slice/emqx.service

           ├─1128 emqx -Bd -spp true -A 4 -IOt 4 -SDio 8 -C multi_time_warp -e 262144 -zdbbl 8192 -Q 1048576 -P 2097152 -- -root /usr/lib/emqx -bindir /usr/lib...

           ├─1893 erl_child_setup 1048576

           ├─1915 /usr/lib/emqx/lib/os_mon-2.9.1/priv/bin/memsup

           ├─1916 /usr/lib/emqx/lib/os_mon-2.9.1/priv/bin/cpu_sup

           ├─1918 /usr/lib/emqx/erts-14.2.5/bin/inet_gethost 4

           └─1919 /usr/lib/emqx/erts-14.2.5/bin/inet_gethost 4

7月 28 19:22:58 localhost.localdomain bash[1128]: WARNING: Default (insecure) Erlang cookie is in use.

7月 28 19:22:58 localhost.localdomain bash[1128]: WARNING: Configure node.cookie in /etc/emqx/emqx.conf or override from environment variable EMQX_NODE__COOKIE

7月 28 19:22:58 localhost.localdomain bash[1128]: WARNING: NOTE: Use the same cookie for all nodes in the cluster.

7月 28 19:23:00 localhost.localdomain emqx[1886]: EXEC: /usr/lib/emqx/erts-14.2.5/bin/erlexec -enable-feature maybe_expr -noinput -noshell +Bd -boot /usr/lib/...

7月 28 19:23:03 localhost.localdomain bash[1128]: Listener tcp:default on 0.0.0.0:1883 started.

7月 28 19:23:03 localhost.localdomain bash[1128]: Listener ssl:default on 0.0.0.0:8883 started.

7月 28 19:23:03 localhost.localdomain bash[1128]: Listener ws:default on 0.0.0.0:8083 started.

7月 28 19:23:03 localhost.localdomain bash[1128]: Listener wss:default on 0.0.0.0:8084 started.

7月 28 19:23:04 localhost.localdomain bash[1128]: Listener http:dashboard on :18083 started.

7月 28 19:23:04 localhost.localdomain bash[1128]: EMQX 5.7.1 is running now!

Hint: Some lines were ellipsized, use -l to show in full.

[root@localhost ~]# ^C

[root@localhost ~]#

2.3 结果

使用MQTT.fx进行连接测试。。。失败。无法连接。

再使用浏览器进行管理,依然失败。

三、尝试解决问题

3.1 结论

进过百度与尝试,先说结论:我安装的Centros7是最简单安装。防火墙的任何一个端口都没打开:

[root@localhost ~]# firewall-cmd --list-all

public (active)

  target: default

  icmp-block-inversion: no

  interfaces: ens160

  sources:

  services: dhcpv6-client ssh

  ports:

  protocols:

  masquerade: no

  forward-ports:

  source-ports:

  icmp-blocks:

  rich rules:

3.2 解决办法

打开防火墙

3.3 打开防火墙

3.3.1 完全关闭防火墙

[root@localhost ~]# systemctl stop firewalld

关闭后,即可在浏览器中正常打开emqx的管理控制台

以及可以使用MQTT.fx链接上emqx服务器。

当然这样子没有防火墙,还是风险很大。不过,在本地的VMware的虚拟主机网络中进行实验,风险很少很低的,这样子操作比较简单粗暴。

3.3.2打开合适的防火墙的端口

3.3.2.1 emqx需要的端口

先让我们看看emqx给出的提示:

[root@localhost ~]# systemctl status emqx

● emqx.service - emqx daemon

   Loaded: loaded (/usr/lib/systemd/system/emqx.service; enabled; vendor preset: disabled)

   Active: active (running) since 日 2024-07-28 19:22:55 CST; 1min 54s ago

 Main PID: 1128 (beam.smp)

   CGroup: /system.slice/emqx.service

           ├─1128 emqx -Bd -spp true -A 4 -IOt 4 -SDio 8 -C multi_time_warp -e 262144 -zdbbl 8192 -Q 1048576 -P 2097152 -- -root /usr/lib/emqx -bindir /usr/lib...

           ├─1893 erl_child_setup 1048576

           ├─1915 /usr/lib/emqx/lib/os_mon-2.9.1/priv/bin/memsup

           ├─1916 /usr/lib/emqx/lib/os_mon-2.9.1/priv/bin/cpu_sup

           ├─1918 /usr/lib/emqx/erts-14.2.5/bin/inet_gethost 4

           └─1919 /usr/lib/emqx/erts-14.2.5/bin/inet_gethost 4

7月 28 19:22:58 localhost.localdomain bash[1128]: WARNING: Default (insecure) Erlang cookie is in use.

7月 28 19:22:58 localhost.localdomain bash[1128]: WARNING: Configure node.cookie in /etc/emqx/emqx.conf or override from environment variable EMQX_NODE__COOKIE

7月 28 19:22:58 localhost.localdomain bash[1128]: WARNING: NOTE: Use the same cookie for all nodes in the cluster.

7月 28 19:23:00 localhost.localdomain emqx[1886]: EXEC: /usr/lib/emqx/erts-14.2.5/bin/erlexec -enable-feature maybe_expr -noinput -noshell +Bd -boot /usr/lib/...

7月 28 19:23:03 localhost.localdomain bash[1128]: Listener tcp:default on 0.0.0.0:1883 started.

7月 28 19:23:03 localhost.localdomain bash[1128]: Listener ssl:default on 0.0.0.0:8883 started.

7月 28 19:23:03 localhost.localdomain bash[1128]: Listener ws:default on 0.0.0.0:8083 started.

7月 28 19:23:03 localhost.localdomain bash[1128]: Listener wss:default on 0.0.0.0:8084 started.

7月 28 19:23:04 localhost.localdomain bash[1128]: Listener http:dashboard on :18083 started.

7月 28 19:23:04 localhost.localdomain bash[1128]: EMQX 5.7.1 is running now!

Hint: Some lines were ellipsized, use -l to show in full.

[root@localhost ~]# ^C

再看看官网的提示:(MQTT 服务器搭建:EMQX 安装指南和常见问题 | EMQ)

(https://www.emqx.com/zh/blog/install-emqx-mqtt-broker)

EMQX 默认情况下监听以下端口:

端口

说明

集群通信

4369-4380

集群通信

5370-5380

集群 RPC 通信

协议接入

1883

MQTT 协议端口

11883

MQTT 协议端口

8883

MQTT/SSL 端口

8083

MQTT/WebSocket 端口

5683

LwM2M 端口

管理监控

8081

HTTP API 端口

18083

Dashboard 管理控制台端口

3.3.2.2 防火墙打开emqx需要的端口

[root@localhost ~]# firewall-cmd --version

0.6.3

[root@localhost ~]# firewall-cmd --list-all

public (active)

  target: default

  icmp-block-inversion: no

  interfaces: ens160

  sources:

  services: dhcpv6-client ssh

  ports:

  protocols:

  masquerade: no

  forward-ports:

  source-ports:

  icmp-blocks:

  rich rules:

[root@localhost ~]#

居然一个开放的端口都没有,最简单的安装。

[root@localhost ~]# firewall-cmd --add-service=http --permanent

success

[root@localhost ~]# firewall-cmd --add-port=18083/tcp --permanent

success

[root@localhost ~]# firewall-cmd --list-all

public (active)

  target: default

  icmp-block-inversion: no

  interfaces: ens160

  sources:

  services: dhcpv6-client ssh

  ports:

  protocols:

  masquerade: no

  forward-ports:

  source-ports:

  icmp-blocks:

  rich rules:

[root@localhost ~]# firewall-cmd --zone=public --add-service=http --permanent

Warning: ALREADY_ENABLED: http

success

[root@localhost ~]# firewall-cmd --reload

success

[root@localhost ~]# firewall-cmd --list-all

public (active)

  target: default

  icmp-block-inversion: no

  interfaces: ens160

  sources:

  services: dhcpv6-client http ssh

  ports: 18083/tcp

  protocols:

  masquerade: no

  forward-ports:

  source-ports:

  icmp-blocks:

  rich rules:

[root@localhost ~]#

提示:Linux系统,在防火墙设置规则后,需要reload进行重启,规则才有效。

成功!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1961551.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Tkinter简介与实战(1)

Tkinter简介与实战---实现一个计算器 Tkinter简介安装环境和安装命令WindowsmacOSLinux 注意事项使用正确的包管理器&#xff1a;检查安装完整性&#xff1a;更新 Python&#xff1a;使用虚拟环境&#xff1a; 一个实战例子-----计算器1.创建窗口&#xff1a;2.创建 GUI 组件&a…

学习大数据DAY27 Linux最终阶段测试

满分&#xff1a;100 得分&#xff1a;72 目录 一选择题&#xff08;每题 3 分&#xff0c;共计 30 分&#xff09; 二、编程题&#xff08;共 70…

ANSYS仿真DDR4的眼图

1 眼图的基本知识 对于数字信号&#xff0c;高低电平转换可以组合在多个序列中。以3位为例&#xff0c;总共有000-111和8种组合。在时域中&#xff0c;根据某个参考点对足够多的序列进行对齐&#xff0c;然后将波形叠加形成眼图&#xff0c;如下图所示。 图&#xff1a;眼图中…

JavaScript object find 示例

https://andi.cn/page/621631.html

从信息论的角度看微博推荐算法

引言 在数字时代&#xff0c;推荐系统已成为社交媒体和其他在线服务平台的核心组成部分。它们通过分析用户行为和偏好&#xff0c;为用户提供个性化的内容&#xff0c;从而提高用户满意度和平台的参与度。推荐系统不仅能够增强用户体验&#xff0c;还能显著提升广告投放的效率…

angular入门基础教程(一)环境配置与新建项目

ng已经更新到v18了&#xff0c;我对他的印象还停留在v1,v2的版本&#xff0c;最近研究了下&#xff0c;与react和vue是越来越像了&#xff0c;所以准备正式上手了。 新官网地址:https://angular.cn/ 准备条件 nodejs > 18.0vscodeng版本18.x(最新的版本) {"name&qu…

C# Unity 面向对象补全计划 之 继承(字段与属性)

本文仅作学习笔记与交流&#xff0c;不作任何商业用途&#xff0c;作者能力有限&#xff0c;如有不足还请斧正 本系列旨在通过补全学习之后&#xff0c;给出任意类图都能实现并做到逻辑上严丝合缝 Q&#xff1a;为什么要单讲继承字段与属性&#xff0c;不讲继承方法了吗&#x…

【SuperMap GIS 信创部署系列】-- 金蝶V10中间件

⼀、安装包获取 本⽂以10.2.1版本安装为例&#xff0c;官⽹下载iserver war包即可。 下载地址&#xff1a;http://support.supermap.com.cn/DownloadCenter/DownloadPage.aspx?id1852 ⼆、部署 iServer.war 1.解压安装包 将下载的supermap-iserver-10.2.1-war.zip包进⾏解…

基于单片机的步进电机系统设计方法探究

摘 要&#xff1a; 单片机是步进电机系统的重要组成部分&#xff0c;对于步进电机系统的驱动控制具有重要的影响。通过分析步进电机系统的工作原理&#xff0c;对步进电机系统进行规划设置。达到降低步进电机的使用成本&#xff0c;提高步进电机的效率与性能的效果。文章主要探…

WIFI 接收机和发射机同步问题+CFO/SFO频率偏移问题

Synchronization Between Sender and Receiver & CFO Correction 解决同步问题和频率偏移问题是下面论文的关键&#xff0c;接下来结合论文进行详细解读 解读论文&#xff1a;Verification and Redesign of OFDM Backscatter 论文pdf&#xff1a;https://www.usenix.org/s…

当自动驾驶遇上扩散模型(Panacea): 生成自动驾驶BEV数据集

Abstract 在自动驾驶领域&#xff0c;对高质量的标注训练数据的需求日益增加。在本文中&#xff0c;我们提出了Panacea&#xff0c;这是一种创新的方法&#xff0c;用于生成驾驶场景中的全景和可控视频&#xff0c;能够生成无限数量的多样化、标注的样本&#xff0c;对于自动驾…

Mojo函数

正如在语言基础中提到的&#xff0c;Mojo支持两种类型的函数&#xff1a;def和fn函数。您可以在任何函数中使用这两种声明方式&#xff0c;包括main()函数&#xff0c;但它们具有不同的默认行为&#xff0c;如本页面所述。 我们认为def和fn都有很好的用例&#xff0c;并且不认…

华为云上如何创建桶

目录 一、进入对象存储服务(OBS)页面,点击【创建桶】二、输入桶的相关信息三、获取 projectId四、获取 OBS Endpoint五、获取 AK/SK一、进入对象存储服务(OBS)页面,点击【创建桶】 二、输入桶的相关信息 可以勾选购买套餐: 点【立即创建】按钮完成桶的创建。 三、获取…

FPGA开发——数码管的使用

一、概述 在我们的日常开发中&#xff0c;数字显示的领域中用得最多的就是数码管&#xff0c;这篇文章也是围绕数码管的静态显示和动态显示进行一个讲解。 1、理论 &#xff08;1&#xff09;数码管原理图 在对数码管进行相关控制时&#xff0c;其实就是对于8段发光二极管和…

LLM还能拿来做异常检测

我从csdn上一路找原文章找到了这一篇 它使用distilbert-base-uncased这个模型给表格数据做文本embedding&#xff0c;并且期望这个LLM已经蕴含了合理的房产相关信息&#xff0c;因此对于没见过的异常房产信息&#xff0c;一定会产生一个与大多数信息embedding都不一样的embedd…

【每日一题】【逆推法 + 贪心】【数学】造数 河南萌新联赛2024第(一)场:河南农业大学 A题 C++

河南萌新联赛2024第&#xff08;一&#xff09;场&#xff1a;河南农业大学 A题 造数 题目描述 样例 #1 样例输入 #1 2样例输出 #1 1样例 #2 样例输入 #2 5样例输出 #2 3做题思路 本题可以用逆推法 将三种操作反过来变为 − 1 , − 2 , / 2 -1 , -2 , /2 −1,−2,/2 …

Linux云计算 |【第二阶段】AUTOMATION-DAY4

主要内容&#xff1a; 部署Ansible、Ansible基础命令&#xff08;Ansible ad-hoc命令格式、Ansible-doc帮助&#xff09;、Ansible模块常用&#xff1a;脚本与命令模块、文件与账户模块、软件与服务模块、逻辑卷模块 补充&#xff1a;touch 除创建文件外&#xff0c;若再创建相…

DBMotion x Chat2DB:高效迁移,优雅同步,数据腾飞不再愁

DBMotion 基本介绍 数据传输服务DBMotion是一款轻量、绿色的数据库迁移、同步、校验工具。支持国产化数据迁移、支持容灾演练、支持两地三中心和异地多活&#xff1b;源库无感知、简单易集成、丝滑高性能。助您在多云之间随心迁移、自由容灾。 功能介绍 已支持的数据库 v1.…

尚品汇-布隆过滤器解决缓存穿透问题(二十四)

目录&#xff1a; &#xff08;1&#xff09;布隆过滤器 &#xff08;2&#xff09;布隆过滤器实现方式 &#xff08;3&#xff09;CompletableFuture异步编排 &#xff08;4&#xff09;CompletableFuture介绍 &#xff08;1&#xff09;布隆过滤器 &#xff08;2&#…

web基础及http协议、

⼀、web基本概念和常识 Web&#xff1a;为⽤户提供的⼀种在互联⽹上浏览信息的服务&#xff0c;Web 服 务是动态的、可交 互的、跨平台的和图形化的。Web 服务为⽤户提供各种互联⽹服务&#xff0c;这些服务包括信息浏览 服务&#xff0c;以及各种交互式服务&#xff0c;包括聊…