-
安装mosquitto
sudo apt install mosquitto sudo apt install libmosquitto-dev sudo apt install mosquitto-clients -
启动mosquitto
默认安装mosquitto后就会自动启动mosquitto进程,其配置文件在/etc/mosquitto下,默认监听端口为1883
/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
查看mosquitto的启动命令# mosquitto -h mosquitto version 1.4.15 (build date Tue, 18 Jun 2019 11:42:22 -0300) mosquitto is an MQTT v3.1.1/v3.1 broker. Usage: mosquitto [-c config_file] [-d] [-h] [-p port] -c : specify the broker config file. (配置文件路径) -d : put the broker into the background after starting. (后台运行) -h : display this help. (显示帮助) -p : start the broker listening on the specified port. Not recommended in conjunction with the -c option. (指定端口) -v : verbose mode - enable all logging types. This overrides any logging options given in the config file. (打印日志) See http://mosquitto.org/ for more information.执行:
mosquitto -p 5678 -v,在本地端口5678上启动mosquitto服务,并在前台运行打印日志 -
订阅
使用mosquitto_sub命令启动订阅,查看mosquitto_sub的启动命令# mosquitto_sub --help mosquitto_sub is a simple mqtt client that will subscribe to a single topic and pr
ubuntu搭建mqtt服务器及验证
于 2022-06-16 19:42:51 首次发布
本文介绍了如何在Ubuntu系统中安装并启动mosquitto MQTT服务器,包括查看启动命令、在特定端口运行服务。同时,详细说明了使用mosquitto_sub进行订阅以及mosquitto_pub发布消息的过程,强调了主题在MQTT中的重要性,并提供了相关命令的实际操作示例。

最低0.47元/天 解锁文章
1280

被折叠的 条评论
为什么被折叠?



