RabbitMQ cluster on a single machine

Viewed 141

I want to create a three node RabbitMQ cluster on a single RHEL8 machine for testing purposes. I tried instructions given in RabbitMQ official guide and also tried to follow this guide. The first node works fine and it's running. However, the second node cannot be started and throws up an error.

I used below commands as mentioned in the guide.

RABBITMQ_NODE_PORT=5672 RABBITMQ_NODENAME=rabbit rabbitmq-server -detached 

RABBITMQ_NODE_PORT=5673 RABBITMQ_NODENAME=hare rabbitmq-server -detached 

rabbitmqctl -n hare stop_app

This command throws up below error.

DIAGNOSTICS

attempted to contact: [hare@localhost]

hare@localhost:

  • connected to epmd (port 4369) on localhost
  • epmd reports: node 'hare' not running at all other nodes on localhost: [rabbit]

On further inspection of logs, it seems like that this node tries to use the same ports used by the first node (e.g. MQTT port 1883).

I think I might have to use the other option of declaring /etc/rabbitmq/rabbitmq.conf. Mainly because it seems to give more options to change ports etc.

A sample config file resembling the one needed in my case or a link to a proper guide is highly appreciated.

1 Answers

You didn't specify, but you must have the MQTT plugin enabled for there to be a conflict on that port, correct?

The easiest work-around would be to have two configuration files specifying different ports for MQTT, AMQP and anything else. Then, use the RABBITMQ_CONFIG_FILE environment variable to point to the appropriate file:

RABBITMQ_NODE_PORT=5672 RABBITMQ_NODENAME=rabbit0 \
    RABBITMQ_CONFIG_FILE=/path/to/rabbitmq-0.conf rabbitmq-server -detached

RABBITMQ_NODE_PORT=5673 RABBITMQ_NODENAME=rabbit1 \
    RABBITMQ_CONFIG_FILE=/path/to/rabbitmq-1.conf rabbitmq-server -detached

NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.

Related