mosquitto安装、配置、测试、paho.mqtt-spy安装
2017-10-13 17:58
218 查看
mosquitto是一款实现了消息推送协议 MQTT v3.1 的开源消息代理软件,提供轻量级的,支持可发布/可订阅的的消息推送模式,使设备对设备之间的短消息通信变得简单,比如现在应用广泛的低功耗传感器,手机、嵌入式计算机、微型控制器等移动设备。
(一) Ubuntu 安装 mosquitto
apt-add-repository ppa:mosquitto-dev/mosquitto-ppa apt-get update apt-get install mosquitto apt-get install mosquitto-clients
(二) 修改/etc/mosquitto/mosquitto.conf
pid_file /var/run/mosquitto.pid persistence true persistence_location /var/lib/mosquitto/ log_dest file /var/log/mosquitto/mosquitto.log # 将其他配置配置到此处方便管理 include_dir /etc/mosquitto/conf.d
(三) mosquitto配置文件[详细参考]
安全配置 (/etc/mosquitto/conf.d/security.conf)
# ================================================================= # Security # ================================================================= # 禁止匿名用户访问 allow_anonymous false # 用户密码配置文件,路径为绝对路径 password_file /etc/mosquitto/pwdfile.example # 访问规则列表 acl_file /etc/mosquitto/aclfile.example
acl_file (/etc/mosquitto/aclfile.example)
# 用户限制 user <username> # 用户可以访问的topic和权限 topic [read|write] <topic>
(四) 新建用户
# 用户格式为<username>:<password> # 第一次创建用户,再次创建会覆盖原文件 mosquitto_passwd -c /etc/mosquitto/pwdfile.example <userName> # 新增用户 mosquitto_passwd -U /etc/mosquitto/pwdfile.example <userName>
(五) 启动服务
service mosquitto start or mosquitto -c /etc/mosquitto/mosquitto.conf -d
(六) 终端测试
订阅 mosquitto_sub -t <topic> -u <username> -P <password>
mosquitto_sub -t mqtt -u hao -P 123456
发布 mosquitto_pub -t <topic> -m <message> -u <username> -P <password>
mosquitto_pub -t mqtt -m message -u hao -P 123456
(七) paho.mqtt-spy图形化界面测试
下载连接 https://github.com/eclipse/paho.mqtt-spy/releases/download/1.0.1-beta5/mqtt-spy-1.0.1-beta-b5-jar-with-dependencies.jar启动paho.mqtt-spy
java -jar mqtt-spy-1.0.1-beta-b5-jar-with-dependencies.jar
(八) 创建paho.mqtt-spy桌面图标
vim ~/.local/share/applications/mqtt-spy.desktop # 添加以下内容
[Desktop Entry] Version=1.0 Name=mqtt-spy Comment=mqtt-spy Type=Application Categories=Development; Exec=java -jar 安装目录/paho.mqtt-spy/jar/mqtt-spy-1.0.1-beta-b5-jar-with-dependencies.jar Terminal=false Icon=安装目录/paho.mqtt-spy/mqtt-spy/src/main/resources/ui/images/mqtt-spy-logo.png
相关文章推荐
- Ubuntu 16.04安装测试MQTT Mosquitto
- Centos7-mqtt消息中间件mosquitto的安装和配置
- MQTT协议 - Mosquitto安装测试
- Centos7-mqtt消息中间件mosquitto的安装和配置
- Mosquitto的安装、配置、测试
- Mosquitto的安装、配置、测试
- MQTT协议学习—Mosquitto安装、测试
- Mosquitto的安装、配置、测试
- Mac 下 Mosquitto 安装和配置 (Mosquitto为开源的mqtt服务器)
- FastDfs安装,配置,测试
- mysql源码包手动安装、配置以及测试(亲测可行)
- windows环境下mosquitto环境搭建与mqtt测试
- svn安装、配置-Apache-Windows(已测试)
- TT数据库,高并发的数据库 安装配置参数及效率测试
- resin服务器安装测试及配置文件说明
- LNMP环境搭建:Nginx安装、测试与域名配置
- ubuntu12.04下nfs安装、配置、测试 .
- [2] MQTT,mosquitto,Eclipse Paho----mosquitto使用扫盲
- 网站压力测试工具 webbench 安装配置
- haproxy + keepalived “一键安装包” 配置与测试HOWTO