Clustering
The RabbitMQ Helper is a tool that streamlines the RabbitMQ clustering process on Windows. For instructions, see Clustering Guide and Quorum Queues.
For Quorum Queues, ensure you have at least three nodes, or your cluster cannot tolerate a node fault.
Be careful not to decommission a node from your cluster without first removing it from the member list of the Quorum Queues. It hosts replicas using the rabbitmq-queues shrink command. And if adding nodes after Quorum Queues has been configured in Secret Server, you must explicitly add the Quorum Queues to the node by using the rabbitmq-queues grow command. For more details, see RabbitMq Quorum Queue Management documentation.
The Helper does not assist with load-balancing. For details, see Load Balancing.
Clustering Prerequisites
When RabbitMQ is installed on a virtual or physical machine, it is already in a cluster of one node. To add another node to the cluster, you need to install RabbitMQ on a different virtual or physical machine and then join either of the nodes to the other cluster. The cluster name is irrelevant and can be changed later.
- Ensure that you have at least three RabbitMQ nodes already installed following the appropriate installation process.
- Ensure that all cluster nodes can resolve each others’ DNS names to the correct IPs.
- Install RabbitMQ on N+1 virtual or physical machines.
-
Check the availability of open firewall for cluster ports:
- Make sure the firewall rule is open for the network type (private/domain only) on each virtual/physical machine where RabbitMQ nodes will be installed.
- Required TCP ports: 4369, 25672,44002.
- See RabbitMQ Clustering to find more about the clustering details.
-
On Erlang versions starting with 20.2, the cookie file locations are:
-
\%HOMEPATH%\.erlang.cookie
(usually C:\Users\%USERNAME%\erlang.cookie for user %USERNAME%) if both HOMEPATH environment variables are set. -
%USERPROFILE%\.erlang.cookie
(usuallyC:\Users\%USERNAME%\.erlang.cookie
) if HOMEPATH is not set.
-
-
For the RabbitMQ Windows service:
%USERPROFILE%\.erlang.cookie
(usuallyC:\WINDOWS\system32\config\systemprofile
). The cookie file used by the Windows service account and the user running CLI tools must be synchronized.
-
For the RabbitMQ Windows service:
%WINDIR%\Users\%USER%\.erlang.cookie
(usually%WINDIR%\Users\%USER%\.erlang.cookie
). The cookie file used by the Windows service account and the user running CLI tools must be synchronized.
Usually, the cookie location is the following: C:\WINDOWS\system32\config\systemprofile. That cookie value is the shared secret for the cluster, so all nodes joining the cluster must use this shared secret. By retrieving the value from the cookie in the above node's location, try to join and use it with the Set ErlangCookieFileCommand on another node. The other node will have its Erlang cookie set to match the first node. Clustering commands join the other node to the first node and then bring the first node into the mirror.
Joining a Cluster Using the RabbitMQ Helper
To join a cluster using the RabbitMQ Helper, run the commands listed below.
-
Set-ErlangCookieFileCommand
—updates the Erlang Cookie file with values given by the user. If two or more nodes want to communicate, they must have the same shared secret called the Erlang cookie. For details, see the Prerequisites section above.You can update the existing erlang cookie file values to the nodes that need to be joined for clustering. Alternatively, use the same command with an arbitrary cookie on all nodes (if you want to use a new value or cannot look the existing one up).
-
Join-RabbitMqCluster
—joins the other node in a cluster.You will likely want to establish policies to replicate your queues. While the above two commands are enough to join three nodes minimum to a cluster, that cluster will not replicate queues without policies. For details, see RabbitMQ Clustering.
Joining a Cluster PowerShell Example
#on the node which you are joining into the target node/cluster
#Use the value for cookie from the target node, collected in the prerequisite steps.
# <cluster-cookie-value> can be found inside the Erlang Cookie File
Set-ErlangCookieFileCommand -CookieContent <cluster-cookie-value> -Verbose
#using the CookieSet and FirewallConfigured will prevent the helper for prompting. Only use if you have actually already set the cluster cookie and you have configured your firewall
#OTHERHOSTNAME is CASE SENSITIVE and is the exact hostname of a machine that you are trying to join this machine into a cluster with.
Join-RabbitMqCluster -StrictHostname OTHERHOSTNAME -CookieSet - FirewallConfigured -Verbose
Clustering a Rabbit Node Without the Helper
Prerequisites
-
Ensure that RabbitMQ is installed and running on each machine you want to include in the cluster
-
Each node must have a unique name. By default, it is rabbit@hostname. You can change this value using the RABBITMQ_NODENAME environment variable
To cluster a Rabbit node in an alternative way:
-
Copy the
.erlang.cookie
from one node to all nodes in the system profile (usuallyC:\Windows\System32\config\systemprofile
) and the user profile running rabbitmqctl.bat. -
Restart the RabbitMQ nodes.
-
Go to the RabbitMQ Bin Directory and run the following reset commands:
-
- rabbitmqctl stop_app
-
- rabbitmqctl reset
An example of the RabbitMQ Bin Directory: -
C:\Program Files\RabbitMQ Server\rabbitmq_server-xx.xx.xx\sbin.
-
-
Join the cluster by running the
- rabbitmqctl join_cluster rabbit@OTHERHOSTNAME
command. -
Start the RabbitMQ nodes by running the
- rabbitmqct start_app
command. -
Verify the cluster by running the
rabbitmqctl cluster_status
command.