一、安装
1、直接安装mqtt包
$ sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa
$ sudo apt-get update
$ sudo apt-get install mosquitto
$ sudo apt-get install mosquitto-clients
2、从github上下载开发包后编译
二、配置
1、添加配置文件
$ vi /usr/etc/mosquitto/mosquitto.conf
port 1883
listener 9005
protocol websockets
2、启动
$ mosquitto -c /usr/etc/mosquitto/mosquitto.conf
三、测试
1、测试监听
$ telnet localhost 9005
$ telnet localhost 1883
2、测试订阅发布
$ mosquitto_sub -h localhost -p 1883 -t "topic" -v
$ mosquitto_pub -h localhost -t "topic" -m "test message"