RabbitMQ setup and cluster configuration on a windows network


 

Queuing has been integral part of application architecture for quite sometime and therefore there are number of frameworks available to let you manage Queue/Bus.

Queue as you may know is used when you have one node to process your message and Bus (Service Bus/Topic) is used when there is more than one node that needs to process the message. RabbitMQ is one of available framework along with MSMQ, Kafka, Azure Service Bus and etc.

RabbitMQ is one of the most popular framework as it can be used to create highly available and fault tolerant cluster of nodes that hold the queue's and message's for processing.

In the writeup we will try to install RabbitMQ cluster on couple of windows machines which can be easily translated to containerised application using docker.

1) To install docker visit RabbitMQ official and download required file, once downloaded execute the exe and follow the wizard.

You may be asked to install Erlang in the process as that is one of the primary requirement for RabbitMQ setup.

2)Repeat step one for each node that will be part of your cluster (it is recommended to have odd number of nodes/machines).

3)From command prompt go to bin folder of installation directory on each machine which would look like "C:\Program Files\RabbitMQ Server\rabbitmq_server-xx.xx.xx\sbin", and execute below.

rabbitmq-plugins enable rabbitmq_management

This will install admin gui which can be accessed using http://localhost:15672, user name and password is guest.

4)Ensure you are using same erlang cookie on all machines. Cookie is stored in .erlang.cookie and location may vary as per OS for windows 10 it is at C:\Windows\System32\config\systemprofile.

If you have issue location this look at the log file, which is typically located in your user %AppData%\Roaming\RabbitMQ\log directory which would have path corresponding to home dir

I did copy cookie from master node on all other machines

5)Enable below on each machine to allow seamless communication

Rule Type

Program path

Specified local ports

Profile

Name

Port

5672, 15672

Domain, Private, Public

RabbitMQ

Program

%ProgramFiles%\erlx.x.x\bin\erl.exe

Domain, Private, Public

Erlang

Program

%ProgramFiles%\erlx.x.x\erts-a.b.c\bin\erl.exe

Domain, Private, Public

Erlang Run-Time System

Program

%ProgramFiles%\erlx.x.x\erts-a.b.c\bin\epmd.exe

Domain, Private, Public

Erlang Port Mapper Daemon


6)Make sure all machines can communicate with each other if not please add entries in respective host files which can be found at C:\Windows\System32\drivers\etc

7)Identify your master node and execute below on all other machines other than the master node.
rabbitmqctl stop_app
rabbitmqctl join_cluster rabbit@masternodemachinename
rabbitmqctl start_app
rabbitmq-plugins enable rabbitmq_federation
rabbitmq-plugins enable rabbitmq_federation_management

8) After above step you have create a cluster and have all you machined to it, now on any machine if you open rabbmitmq ui using http://localhost:15672 and guest/guest as user name/password you will see that they all are part of a cluster like in below case two machines form a cluster and can be seen in nodes section.



9) Now that we have all nodes added in the cluster time to enable mirroring so that is one node goes down application does not. To configure mirroring execute below.

rabbitmqctl set_policy mirror-all “^config” “{“”ha-mode””:””all””}”

10) To configure load balancing have a look at this

If all goes well you have a cluster of RabbitMQ server which if highly available and fault tolerant.

Comments

Popular posts from this blog

Gitflow using source tree

Component analysis for application security

Analyse log using plug and play FileBeat

Introduction to Blazor

.NET MAUI and Blazor to create windows/web and mobile application (.NET 6.0)

Clean Architecture

What Interview Is/Is Not for an interviewer

Estimation techniques

WCAG Accessibility