我如何用蚊子建立我自己的MQTT服务器?

时间:2022-01-15 07:11:32

I am setting up a sensor network for my new diy home automation system and am running into a major roadblock. I am using OpenHAB as the "home base" for the system, and since it has an MQTT binding, I figured that would be a good way to have all of the nodes talk with it. I know that I can connect to test.mosquitto.org, which is great for testing. But, obviously, this is not secure enough by far for the permanent server (also, I'm pretty sure they specifically say not to use that server for permanent things).

我正在为我的新diy家庭自动化系统建立一个传感器网络,并且正在进入一个主要的路障。我使用OpenHAB作为系统的“home base”,并且由于它具有MQTT绑定,所以我认为这将是使所有节点都能与之对话的好方法。我知道我可以连接到test.蚊子。org,这对测试很有用。但是,显然,对于永久服务器来说,这还不够安全(我很确定他们明确地说不要使用服务器来做永久的事情)。

After a lot of Google-ing I have found a decent amount of info on Mosquitto and MQTT, but honestly most of it is over my head since I am just starting. My question here, that most seem to assume is known already, is how do I actually go about setting up my own MQTT server on the Raspberry Pi that will be running everything? Or is this not the norm, and should I find a public server (like test.mosquitto.org)? That just doesn't seem like the most practical method.

经过大量的谷歌搜索,我发现了大量关于蚊子和MQTT的信息,但老实说,大部分都是在我的脑海中,因为我才刚开始。我的问题是,大多数人似乎已经知道了,我是如何在树莓Pi上设置自己的MQTT服务器的?或者这不是标准,我应该找一个公共服务器(像test.蚊子。org)吗?这似乎不是最实用的方法。

Thanks in advance for your help.

谢谢你的帮助。

2 个解决方案

#1


5  

Mosquitto is light enough that you can install it anywhere. I would only use test.mosquitto.org if I was testing as it is public (ie. anyone can see your data!) and isn't always up and working.

蚊子足够轻,你可以在任何地方安装它。如果我是公开测试的话,我只会使用test.蚊子。org。任何人都能看到你的数据!)而且并不总是在工作。

When running on the pi I normally add the Mosquitto Debian Repo as it is more upto date. Has v1.3.5

当我在pi上运行时,我通常会把蚊子添加到Debian里,因为它是最新的。有v1.3.5

Good instructions on mosquitto.org site or a good beginnners howto over at jpmens, just do the installation upto the TLS part (unless you need it!)

在jpmens上,你可以在蚊子的网站上找到好的指示,或者是一个好的开始,只要把它安装到TLS部分就行了(除非你需要它!)

#2


3  

On a raspberry pi

在一个覆盆子π

If you just run the following commands:

如果您只是运行以下命令:

sudo apt-get update

sudo apt-get更新

sudo apt-get install mosquitto

sudo apt-get安装mosquitto

sudo update-rc.d mosquitto defaults

sudo update-rc。d mosquitto违约

(I'm not 100% sure you need this one but it won't hurt)

(我不是百分百确定你需要这个,但它不会伤害你)

sudo /etc/init.d/mosquitto start

sudo /etc/init.d / mosquitto开始

(only needed this time, as it should start automatically on reboot)

(只需要这一次,因为它应该在重新启动时自动启动)

That will give you a mosquitto broker running on your pi

这样你就可以在你的pi上运行一个蚊子。

#1


5  

Mosquitto is light enough that you can install it anywhere. I would only use test.mosquitto.org if I was testing as it is public (ie. anyone can see your data!) and isn't always up and working.

蚊子足够轻,你可以在任何地方安装它。如果我是公开测试的话,我只会使用test.蚊子。org。任何人都能看到你的数据!)而且并不总是在工作。

When running on the pi I normally add the Mosquitto Debian Repo as it is more upto date. Has v1.3.5

当我在pi上运行时,我通常会把蚊子添加到Debian里,因为它是最新的。有v1.3.5

Good instructions on mosquitto.org site or a good beginnners howto over at jpmens, just do the installation upto the TLS part (unless you need it!)

在jpmens上,你可以在蚊子的网站上找到好的指示,或者是一个好的开始,只要把它安装到TLS部分就行了(除非你需要它!)

#2


3  

On a raspberry pi

在一个覆盆子π

If you just run the following commands:

如果您只是运行以下命令:

sudo apt-get update

sudo apt-get更新

sudo apt-get install mosquitto

sudo apt-get安装mosquitto

sudo update-rc.d mosquitto defaults

sudo update-rc。d mosquitto违约

(I'm not 100% sure you need this one but it won't hurt)

(我不是百分百确定你需要这个,但它不会伤害你)

sudo /etc/init.d/mosquitto start

sudo /etc/init.d / mosquitto开始

(only needed this time, as it should start automatically on reboot)

(只需要这一次,因为它应该在重新启动时自动启动)

That will give you a mosquitto broker running on your pi

这样你就可以在你的pi上运行一个蚊子。