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博客

相关推荐
ZFSS5 分钟前
BYOK(自带密钥)使用指南
运维·服务器·前端·人工智能·midjourney
无足鸟ICT8 分钟前
【RHCA+】编辑多个文件
linux
fengyehongWorld23 分钟前
Linux fd命令
linux
AIMath~24 分钟前
hermes agent安装在Linux centos中
linux·运维·服务器
cjp56024 分钟前
001.Web Api_服务器,新建api
运维·服务器
赵民勇25 分钟前
如何查看一个二进制程序是否设置了rpath或runpath?
linux·c++
小王师傅6632 分钟前
深入解析:Docker在Mac上的运行本质与Linux进程管理机制
linux·macos·docker
Irissgwe42 分钟前
9、数据链路层
linux·网络·mac·ip·数据链路层·arp协议·以太网帧格式
lwprain1 小时前
Umi-ocr2.1.5的linux部署,仅做记录
linux·服务器·umi-ocr
鹏大师运维1 小时前
统信UOS安装Subtitle Edit并使用Edge-TTS生成AI语音教程
linux·前端·人工智能·edge·麒麟·统信uos·ai语音