我们可以在 RabbitMQ 中选择下一个主节点吗?

Can we choose next master node in RabbitMQ?

我们可以更喜欢一个从节点成为主节点而不是另一个从节点吗?假设我想选择下一个主节点作为具有最少主节点或在当前主节点出现故障时具有最大可用资源的节点。可以组织吗?

你可以看看x-queue-master-locator政策。 在这里阅读: https://www.rabbitmq.com/ha.html

Queue Master Location Every queue in RabbitMQ has a home node. That node is called queue master. All queue operations go through the master first and then are replicated to mirrors. This is necessary to guarantee FIFO ordering of messages.

Queue masters can be distributed between nodes using several strategies. Which strategy is used is controlled in three ways, namely, using the x-queue-master-locator queue declare argument, setting the queue-master-locator policy key or by defining the queue_master_locator key in the configuration file. Here are the possible strategies and how to set them:

Pick the node hosting the minimum number of masters: min-masters Pick the node the client that declares the queue is connected to: client-local Pick a random node: random

我还建议阅读此 post: https://www.erlang-solutions.com/blog/take-control-of-your-rabbitmq-queues.html

这应该对你有帮助