树莓派安装mqtt服务器

零、缘起

       看到目前各大云平台都搭建自己的mqtt服务器,本想直接用作项目。奈何算了下成本,实在太贵。尝试自己搭建mqtt服务器,遂拿尘封已久的树莓派进行测试。

一、安装

  1. wget -c https://github.com/eclipse/mosquitto/archive/v1.4.11.tar.gz
  2. tar zxvf v1.4.11.tar.gz
  3. cd mosquitto-1.4.11
  4. sudo apt install cmake g++ libssl-dev libc-ares-dev uuid-dev xsltproc docbook-xsl
  5. mkdir build
  6. cd build
  7. cmake ..
  8. make
  9. sudo make install

错误(安装的时候遇到错误,未解决,但不影响)

running /sbin/ldconfig 2>&1
CMake Error at man/cmake_install.cmake:36 (file):
  file INSTALL cannot find
  "/home/pi/mosquitto-1.4.11/man/mosquitto_passwd.1".
Call Stack (most recent call first):
  cmake_install.cmake:49 (include)

Makefile:115: recipe for target 'install' failed
make: *** [install] Error 1

三、配置账号和密码

      1、生成账号密码

添加用户'abc'密码’xxx

#mosquitto_passwd -c ./pwfile.example abc

输入两遍密码

      2、修改配置文件(mosquitto.conf 

                 2.1 、关闭匿名访问

                  allow_anonymous false

                 2.2、配置用户和密码文件路径

                  password_file ../build/pwfile.example

四、测试

         4.1指定配置文件启动

                   mosquitto -c ./mosquitto-1.4.14/mosquitto.conf 

         4.2 测试

                  4.2.1订阅

                   mosquitto_sub  -t test_topic -u 账户 -P 密码

                  4.2.2发布

                   mosquitto_pub -t test_topic  -u 账户 -P 密码 -m "消息"

参考:

https://www.jianshu.com/p/f8d824afbe3d

http://blog.csdn.net/u012377333/article/details/69397124

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

若云流风

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值