-
安装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 首次发布