mqtt mosquitto桥水平缩放 [英] mqtt mosquitto bridge horizontal scaling

查看:136
本文介绍了mqtt mosquitto桥水平缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个负载均衡器,即aws elb 所有的发布/订阅都将通过该Elb来 两名蚊子经纪人A&肘下的蚊子经纪人B 一个mosquitto代理在这两个代理(mosquitto.broker.sync)之间同步主题

I have one load balancer i.e aws elb all the pub/sub will be coming via that elb two mosquitto broker A & mosquitto broker B under elb one mosquitto broker to sync topic between this two brokers(mosquitto.broker.sync)

这是用于在节点A和B之间同步主题的mosquitto代理的配置的样子

this is how the configuration for mosquitto broker which sync topics between node A and B looks alike

mosquitto.broker.sync: ##
connection mosquitto-bridge
try_private false
address mosquitto.broker.A:1883 mosquitto.broker.B:1883
start_type automatic
round_robin true
notifications true
topic # both 2 "" ""

但是,仅连接到mosquitto.broker.A而不连接到mosquitto.broker.B,这是行不通的

But this is not working it only connecting to mosquitto.broker.A and not connecting to mosquitto.broker.B

先撤消所有尝试

所以我尝试了另一种方法 从mosquitto.broker.sync中删除了所有网桥配置(只是为了避免循环)

so I tried it other way round removed all the bridge config from mosquitto.broker.sync (just to avoid loops)

并将此配置添加到节点上

and added this config onto nodes

mosquitto.broker.A:##

mosquitto.broker.A: ##

connection mosquitto-bridge
try_private false
address mosquitto.broker.sync:1883
start_type automatic
round_robin true
notifications true
topic # both 2 "" ""

mosquitto.broker.B:##

mosquitto.broker.B: ##

connection mosquitto-bridge
try_private false
address mosquitto.broker.sync:1883
start_type automatic
round_robin true
notifications true
topic # both 2 "" ""

mosquitto.broker.sync:##

mosquitto.broker.sync: ##

#connection mosquitto-bridge
#try_private false
#address mosquitto.broker.A:1883 mosquitto.broker.B:1883
#start_type automatic
#round_robin true
#notifications true
#topic # both 2 "" ""

但是在这种情况下,我在其上发送消息的节点被复制了

But in this case the node on which I send the message is been duplicated over it

推荐答案

第一次尝试,问题是因为address字段是要按顺序尝试连接的代理列表,而不是要连接的代理列表同时连接.

For the first attempt, the problem is because the address field is a list of brokers to try and connect to in order, not a list of brokers to be connected simultaneously.

此列表的解释方式取决于round_robin设置.

How this list is interpreted depends on the round_robin setting.

如果设置为 true ,则代理将连接到列表中的第一个,当连接断开时,它将尝试列表中的下一个,在每次重新连接时将列表向下移动.

If set to true then the broker will connect to the first in the list and when the connection drops it will try the next in the list, moving down the list on each reconnect.

如果设置为 false ,它将连接到第一个,并将其视为首选连接.当连接断开时,它将尝试重新连接,如果连接失败,它将在列表中向下移动,但会定期尝试重新连接到列表中的拳头.

If set to false it will connect to the first and treat this as the preferred connection. When the connection drops it will try and reconnect, if it fails it will move down the list, but periodically try and reconnect to the fist in the list.

要真正解决您的问题,请尝试以下操作:

To actually solve your problem try something like this:

mosquitto.broker.A

mosquitto.broker.A

connection sync-a
try_private false
address mosquitto.broker.sync:1883
notifications true
topic # out 2 "" A/
topic # in 2 "" B/

mosquitto.broker.B

mosquitto.broker.B

connection sync-b
try_private false
address mosquitto.broker.sync:1883
notifications true
topic # out 2 "" B/
topic # in 2 "" A/

并保持同步计算机原样.

And leave the sync machine as it is.

这使用主题前缀来确保不形成循环.这也意味着您可以跟踪所有代理在同步计算机上执行的操作,因为所有主题都以它们来自的计算机为前缀.

This uses topic prefixes to ensure no loops are formed. It also means you can keep track of which broker is doing what on the sync machine as all topics are prefixed with the machine they came from.

这篇关于mqtt mosquitto桥水平缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆