Ubuntu MQTT mosquitto

https://github.com/eclipse/paho.mqtt.c.git

https://github.com/eclipse/paho.mqtt.cpp.git

Paho MQTT C Client Library: MQTT Client library for C (MQTTClient)

GitHub - eclipse/mosquitto: Eclipse Mosquitto - An open source MQTT broker

  1. install:

https://mosquitto.org/download/

  1. conf:

打开/etc/mosquitto/mosquitto.conf,发现需要将配置文件放置于/etc/mosquitto/conf.d/目录下,示例文件可以从/usr/share/doc/mosquitto/examples/目录下提取,发现其是一个压缩包,将其解压缩,然后复制到/etc/mosquitto/conf.d/目录下。

xx@ubuntu:/etc/mosquitto$ cd /usr/share/doc/mosquitto/examples/

xx@ubuntu:/usr/share/doc/mosquitto/examples$ ls -lh

总用量 24K

-rw-r--r-- 1 root root 230 Apr 3 2021 aclfile.example

-rw-r--r-- 1 root root 12K Apr 3 2021 mosquitto.conf.gz

-rw-r--r-- 1 root root 23 Apr 3 2021 pskfile.example

-rw-r--r-- 1 root root 355 Apr 3 2021 pwfile.example

cd /usr/share/doc/mosquitto/examples/

sudo gzip -d mosquitto.conf.gz

sudo cp mosquitto.conf /etc/mosquitto/conf.d/

手动启动mosquitto,方便查看日志排查出现的问题。

mosquitto -c /etc/mosquitto/conf.d/mosquitto.conf -v

配置成无用户密码校验和无TLS连接

listener 1883

allow_anonymous true

配置文件如上配置,然后启动mosquito。

  1. stat:

service mosquitto status // 查看服务状态

service mosquitto start // 启动

service mosquitto stop // 停止

service mosquitto restart // 重启

  1. test:

mosquitto_sub -h "192.168.10.111" -p 1883 -t "mqtt/test" -v

mosquitto_pub -h "192.168.10.111" -p 1883 -t "mqtt/test" -m "hello"

Reference:

Ubuntu mosquitto 安装及配置-CSDN博客

ubuntu上安装mosquitto服务_mosquitto ubuntu-CSDN博客

Linux Ububtu下安装MQTT服务器_ubuntu安装mqtt-CSDN博客

相关推荐
寂柒5 小时前
序列化与反序列化
linux·网络
lay_liu5 小时前
ubuntu 安装 Redis
linux·redis·ubuntu
曾经拒绝刘亦菲6 小时前
Clamav在麒麟V10离线安装指南
运维
志栋智能6 小时前
超自动化巡检:应对复杂IT环境的必然选择
运维·网络·安全·web安全·自动化
li星野6 小时前
[特殊字符] Linux/嵌入式Linux面试模拟卷
linux·运维·面试
JiMoKuangXiangQu7 小时前
Linux 锁 (4) - seqlock
linux·seqlock
xlp666hub7 小时前
如果操作GPIO可能导致休眠,那么同步机制绝不能采用spinlock
linux·面试
一直都在5727 小时前
深入理解 synchronized:到底锁的是谁?
运维·服务器
RisunJan7 小时前
Linux命令-mkbootdisk(可建立目前系统的启动盘)
linux·运维·服务器
Sst的头号粉丝8 小时前
Docker——compose
运维·docker·容器