Skip to content

Instantly share code, notes, and snippets.

@neolaw84
Last active May 6, 2021 01:22
Show Gist options
  • Save neolaw84/ada10b6d2b874477b4368ee488b6f161 to your computer and use it in GitHub Desktop.
Save neolaw84/ada10b6d2b874477b4368ee488b6f161 to your computer and use it in GitHub Desktop.
Notes on RabbitMQ Clustering

Notes on RabbitMQ Clustering

RabbitMQ Clustering

I have experiences working in single-node RabbitMQ server. However, I don't have much experiences in a RabbitMQ cluster. This is the gist for myself after going through https://www.rabbitmq.com/clustering.html

Ways of Forming a Cluster

A RabbitMQ cluster can formed in a number of ways:

  • Declaratively by listing cluster nodes in config file
  • Declaratively using DNS-based discovery
  • Declaratively using AWS (EC2) instance discovery (via a plugin)
  • Declaratively using Kubernetes discovery (via a plugin)
  • Declaratively using Consul-based discovery (via a plugin)
  • Declaratively using etcd-based discovery (via a plugin)
  • Manually with rabbitmqctl

All RabbitMQ brokers start out as running on a single node. These nodes can be joined into clusters, and subsequently turned back into individual brokers again.

Node Names

Node names take the form: prefix@full.dns.path . For example, rabbit@node1.uuid.aws.com

If a system uses fully qualified domain names (FQDNs) for hostnames, RabbitMQ nodes and CLI tools must be configured to use so called long node names. For server nodes this is done by setting the RABBITMQ_USE_LONGNAME environment variable to true. For CLI tools, either RABBITMQ_USE_LONGNAME must be set or the --longnames option must be specified.

Ports

  • 4369: epmd, a peer discovery service used by RabbitMQ nodes and CLI tools
  • 5672, 5671: used by AMQP 0-9-1 and 1.0 clients without and with TLS
  • 25672: used for inter-node and CLI tools communication (Erlang distribution server port) and is allocated from a dynamic range (limited to a single port by default, computed as AMQP port + 20000). Unless external connections on these ports are really necessary (e.g. the cluster uses federation or CLI tools are used on machines outside the subnet), these ports should not be publicly exposed. See networking guide for details.
  • 35672-35682: used by CLI tools (Erlang distribution client ports) for communication with nodes and is allocated from a dynamic range (computed as server distribution port + 10000 through server distribution port + 10010). See networking guide for details.
  • 15672: HTTP API clients, management UI and rabbitmqadmin (only if the management plugin is enabled)
  • 61613, 61614: STOMP clients without and with TLS (only if the STOMP plugin is enabled)
  • 1883, 8883: (MQTT clients without and with TLS, if the MQTT plugin is enabled
  • 15674: STOMP-over-WebSockets clients (only if the Web STOMP plugin is enabled)
  • 15675: MQTT-over-WebSockets clients (only if the Web MQTT plugin is enabled)

Replication

State/Data is replicated. Queues (by default) are not.

No master/slave configuration.

Authentication

Shared secret called Erlang cookie. It is in local file with 600 or 400 permission.

Error and Possible Causes

"Connection attempt from disallowed node" and/or "Could not auto-cluster": Erlang cookie does not match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment