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

相关推荐
Gold Steps.几秒前
Docker容器部署elasticsearch8.*与Kibana8.*版本使用filebeat采集日志
运维·docker·云原生·es
m0_6371469317 分钟前
C语言基础面试问答
运维·服务器
t1987512821 分钟前
Linux 上的 Tomcat 端口占用排查
linux·tomcat·firefox
小狗爱吃黄桃罐头41 分钟前
正点原子[第三期]Arm(iMX6U)Linux移植学习笔记-12.1 Linux内核启动流程简介
linux·arm开发·学习
ricky_fan1 小时前
window下配置ssh免密登录服务器
运维·服务器·ssh
地衣君1 小时前
Ubuntu 配置使用 zsh + 插件配置 + oh-my-zsh 美化过程
linux·运维·ubuntu
2401_858286112 小时前
OS11.【Linux】vim文本编辑器
linux·运维·服务器·编辑器·vim
朱包林2 小时前
day27-shell编程(自动化)
linux·运维·服务器·网络·shell脚本
钢铁男儿2 小时前
一文掌握 Tombola 抽象基类的自动化子类测试策略
运维·自动化
kaede2 小时前
Linux实现线程同步的方式有哪些?
linux·运维·云计算