
RabbitMQ is an open-source message queuing software implemented in Erlang OTP. It implements the AMQP (Advanced Message Queuing Protocol), a messaging protocol that enables conforming client applications to communicate with conforming messaging middleware brokers. In addition, RabbitMQ uses plugins to communicate with popular messaging solutions like MQTT (Message Queuing Telemetry Transport) and Streaming Text Oriented Messaging Protocol.
Failure of a single server instance can cause a single point of failure. To avoid this situation, we install a RabbitMQ cluster. This achieves higher availability and throughput compared to a single instance VPS service. In this article, you'll learn how to install and configure a RabbitMQ Cluster on Ubuntu 20.04 Server.
For all the deployed servers, one will be used to join the other nodes to the cluster. All the nodes in the cluster are peer nodes; that is, all the nodes are the same, and none supersedes the other functionally. In this article, we will use two peer nodes, for example:
On node rabbitmq-1 change the static hostname to rabbitmq-1.
On node rabbitmq-2 change the static hostname to rabbitmq-2.
SSH to all the servers as a non-root user with sudo access and edit host file /etc/hosts in all the nodes.
Add the following code in the file.
Ping all the nodes using their hostnames.
Reboot all the nodes for hostname changes to reflect.
RabbitMQ peer nodes and CLI tools use a cookie to determine whether they can communicate with each other. For two nodes to communicate, they must have the same shared secret called the Erlang cookie.
Copy Cookie from rabbitmq-1 node to rabbitmq-2. If there are other nodes, copy to them too.
Go to rabbitmq-1 node, open the file and copy all the contents.
Go to rabbitmq-2 node, open the file and paste contents from rabbitmq-1. Then, do that to all other remaining nodes in cases of any.
All the other RabbitMQ peer nodes should be reconfigured to join the cluster on the first node rabbitmq-1. This step should be for all nodes except for the first one.
Restart RabbitMQ service.
Stop the application.
Reset rabbitmq.
Join the node to the cluster.
Start the application process.
Check the status of the cluster.
Create a HA policy on all the nodes to allow queue mirroring to all nodes in the cluster. Perform this on all nodes.
List configured policies.
Enable RabbitMQ Management Dashboard for all the nodes to access all peer node stats from a specific dashboard.
After enabling the plugins for the web management portal, you can go to your browser and access the page through http://your_IP:15672. Example:
Login with admin as your username and SecurePassword as your password. Make sure you modify the SecurePassword to your own password. Log in is only possible for servers with administrator account activated. Step 5 explains how to.
To access your dashboard from your preferred server, you can add an administrator account to access it.
Default user guest can only log in via localhost. Create an administrator account to access the dashboard. Make sure you modify the SecurePassword to your own password.
You have now installed RabbitMQ Cluster on your server. Your administrator account on all the peer nodes will enable you to have all access privileges to the server. You can now configure your RabbitMQ clusters from the dashboard.
For more information on RabbitMQ clustering, please see the official documentation.
0 Comments
Be the first to comment and share your perspective with the community.