1. 添加epel库
[root@t10 ~]# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@t10 ~]# ll /etc/yum.repos.d/epel*
-rw-r--r--. 1 root root 1050 Sep 18 2019 /etc/yum.repos.d/epel.repo
-rw-r--r--. 1 root root 1149 Sep 18 2019 /etc/yum.repos.d/epel-testing.repo
2. Mosquitto描述
# 只支持 MQTT 3协议
[root@t10 ~]# yum info mosquitto
...
Available Packages
Name : mosquitto
Arch : x86_64
Version : 1.6.10
Release : 1.el7
Size : 287 k
Repo : epel/x86_64
Summary : An Open Source MQTT v3.1/v3.1.1 Broker
URL : http://mosquitto.org/
License : BSD
Description : Mosquitto is an open source message broker that implements the MQ Telemetry
: Transport protocol version 3.1 and 3.1.1 MQTT provides a lightweight method
: of carrying out messaging using a publish/subscribe model. This makes it
: suitable for "machine to machine" messaging such as with low power sensors
: or mobile devices such as phones, embedded computers or micro-controllers
: like the Arduino.
3. 安装
[root@t10 ~]# yum install mosquitto
...
Dependencies Resolved
=================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================
Installing:
mosquitto x86_64 1.6.10-1.el7 epel 287 k
Installing for dependencies:
libuv x86_64 1:1.38.0-2.el7 epel 148 k
libwebsockets x86_64 3.0.1-2.el7 epel 118 k
Transaction Summary
=================================================================================================================================
Install 1 Package (+2 Dependent packages)
...
4. 相关命令
[root@t10 ~]# mosquitto
mosquitto mosquitto_passwd mosquitto_pub mosquitto_rr mosquitto_sub
5. 启动
[root@t10 ~]# mosquitto
1599633468: mosquitto version 1.6.10 starting
1599633468: Using default config.
1599633468: Opening ipv4 listen socket on port 1883.
1599633468: Opening ipv6 listen socket on port 1883.
...
# 开放的端口
[root@t10 ~]# netstat -ntlp|grep mos
tcp 0 0 0.0.0.0:1883 0.0.0.0:* LISTEN 1560/mosquitto
tcp6 0 0 :::1883 :::* LISTEN 1560/mosquitto
6. 配置文件
Mosquitto配置文件的绝对路径 /etc/mosquitto/mosquitto.conf
7. 测试
# 订阅端
[root@t10 ~]# mosquitto_sub -t testdemo
this is a message
# 发布端
[root@t10 ~]# mosquitto_pub -t testdemo -h localhost -m "this is a message"