LINUX--mosquitto

1、 安装mosquitto

sudo apt-get install mosquitto mosquitto-clients

2、 卸载mosquitto

(1) 卸载mosquitto

sudo apt-get remove mosquitto

(2) 卸载mosquitto及其依赖文件

sudo apt-get remove --auto-remove mosquitto

(3) 删除配置文件

sudo apt-get purge mosquitto
sudo apt-get purge --auto-remove mosquitt

3、 mosquitto运行流程

(1) 机器3运行mosquitto –p 4840 命令,建立MQTT Server,-p指定监听端口,不指定情况下默认监听端口1883。

(2) 机器2运行client1:  mosquito_sub –h 10.111.111.111 –p 4840 –t test,建立一个订阅。-h指定要连接的MQTT Server主机地址,-t指定订阅的MQTT topic。

(3) 机器1运行client2:  mosquito_sub –h 10.111.111.111 –p 4840 –t test,建立一个topic为test的订阅。

(4) 机器1另开一个窗口,运行 mosquito_pub –h 10.111.111.111 –p 4840 –t test –m hello,word,建立发布。-m指定要发布的message。

(5) client1与client2收到发布的消息hello,world。

mosquitto等其他参数详见文档:

mosquitto 参数:

-c--config-file 从文件中载入配置

-d--daemon 作为守护进程,后台运行mosquitto

-p--port 在指定的端口上监听,默认是1883

-v--verbose 详细记录信息

mosquitto_sub 参数:

 

mosquitto_pub

posted @ 2017-10-13 20:53  未闻花开  阅读(1372)  评论(0编辑  收藏  举报