Rapsberry install mosquitto mqtt server(1)

安装mosquitto mqtt 服务器

https://www.switchdoc.com/2018/02/tutorial-installing-and-testing-mosquitto-mqtt-on-raspberry-pi/

https://learn.adafruit.com/diy-esp8266-home-security-with-lua-and-mqtt/configuring-mqtt-on-the-raspberry-pi

https://blog.csdn.net/zintiger/article/details/103937400

Installing the MQTT “mosquitto”

sudo wget https://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key
cd /etc/apt/sources.list.d/
sudo wget http://repo.mosquitto.org/debian/mosquitto-stretch.list
sudo apt-get update
sudo apt-get install mosquitto

install the three parts of Mosquitto proper.

1 mosquitto

2 sudo apt-get install mosquitto mosquitto-clients

3 paho-mqtt -the Python language bindings

use MQTT in a Python project

sudo apt-get install mosquitto mosquitto-clients
sudo apt-get install python-pip
sudo pip install paho-mqtt

Configuring and Starting the Mosquitto Server

sudo nano /etc/mosquitto/mosquitto.conf

# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

pid_file /var/run/mosquitto.pid

persistence true
persistence_location /var/lib/mosquitto/
log_type error
log_type warning
log_type notice
log_type information
 
connection_messages true
log_timestamp true

log_dest file /var/log/mosquitto/mosquitto.log

include_dir /etc/mosquitto/conf.d

Starting the Mosquitto Server

Open up two more terminal windows.

In Terminal window 1 type:
mosquitto_sub -d -t hello/world

n Terminal window 2 type: mosquitto_pub -d -t hello/world -m “Hello from Terminal window 2!”

When you have done the second statement you should see this in the Terminal 1 window.~ $ sudo mosquitto_sub -d -t hello/world

Client mosqsub/3014-LightSwarm sending CONNECT
Client mosqsub/3014-LightSwarm received CONNACK
Client mosqsub/3014-LightSwarm sending SUBSCRIBE (Mid: 1, Topic: hello/world, QoS: 0)
Client mosqsub/3014-LightSwarm received SUBACK
Subscribed (mid: 1): 0
Client mosqsub/3014-LightSwarm received PUBLISH (d0, q0, r0, m0, 'hello/world', ... (32 bytes))
Greetings from Terminal window 2

Now you are running the Mosquitto broker successfully.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值