A RabbitMQ cluster is a feature that enables the synchronization of state data and configurations of multiple nodes, in a real-time networked environment. It adds failover protection and, in some cases, performance gains.
Procedure
To create a RabbitMQ cluster:
-
Copy the .erlang.cookie files from the master node:
By default in a Windows system, there is an .erlang.cookie file in two different locations in the master node. They are found in:
- C:\Windows\System32\config\systemprofile
- %HOMEDRIVE%%HOMEPATH%
This usually leads to C:\Users\<username>
- Copy the cookies from each location and overwrite the cookie files in the same file path of the destination nodes.
-
Copy the following certificate files from the master node and overwrite them to the
other nodes:
- CACert.pem
- Cert.pem
- Fingerprint.txt
- Key.pem
By default, these files are found in C:\Program Files (x86)\Genetec\RabbitMQ\.
Modify the RabbitMQ configuration files on the master node to enable partition handling:
-
Right-click the Notepad application, select Run as
administrator, and then open the RabbitMQ.config file in
Notepad.
By default, the RabbitMQ configuration file, RabbitMQ.config, is found in C:\Program Files (x86)\Genetec\RabbitMQ\.Tip: Using Notepad++ with MATLAB set as language improves the readability of the file.
-
Navigate to line 118 and add a comma after the
}
in the lines of code as shown: -
Navigate to line 303 and modify it from:
to:By removing theCodeCode
%% {cluster_partition_handling, ignore},
{cluster_partition_handling, pause_minority}
%%
symbol, the line is no longer flagged as a comment and becomes part of the code. - Save the file.
Reinstall the RabbitMQ service to enable the configuration file changes:
-
Right-click the RabbitMQ Command Prompt (sbin dir) application and select
Run as administrator.
This is installed with RabbitMQ by default.
-
Execute the following commands:
-
rabbitmq-service.bat remove
When successfully executed, the following message is displayed:C:\Program Files\erl10.2\erts-10.2\bin\erlsrv: Service RabbitMQ removed from system
-
rabbitmq-service.bat install
When successfully executed, the following message is displayed:C:\Program Files\erl10.2\erts-10.2\bin\erlsrv: Service RabbitMQ added to system
-
rabbitmq-service.bat start
When successfully executed, the following message is displayed:The RabbitMQ service is starting. The RabbitMQ service was started successfully.
-
Ensure that your modified configuration file is loaded in memory:
-
In the RabbitMQ Command Prompt application, execute the following command:
rabbitmqctl.bat environment
When successfully executed, the content of the RabbitMQ.config loaded in memory and the following message is displayed:Application environment of node rabbit@<User>
-
Verify that your modifications have been implemented correctly:
-
Ensure that line 303 of the displayed file reads as follows:
Code
{cluster_partition_handling, pause_minority}
- If the line of code does not read as in the previous step, modify it to match.
-
Ensure that line 303 of the displayed file reads as follows:
Copy the modified RabbitMQ.config file to the other nodes:
-
Copy the modified RabbitMQ.config file from the master node.
The default location of the config file is C:\Program Files (x86)\Genetec\RabbitMQ\.
-
Overwrite the existing RabbitMQ.config file in the same file path
of the destination nodes.
It is recommended to do a backup before you overwrite the existing files.
- Reinstall RabbitMQ service for each node.
Parent topic: Configuring failover for RabbitMQ