Introduction
RabbitMQ is an open-source message broker that supports multiple messaging protocols. It is widely used for building distributed systems and can be clustered for scalability and high availability. This guide will walk you through the installation of a RabbitMQ cluster on Ubuntu 22.04, which can be effectively hosted on a Windows VPS UK.
Prerequisites
- Two or more servers running Ubuntu 22.04
- Root access or sudo privileges
- Basic knowledge of Linux commands
- Installed Erlang (RabbitMQ dependency)
Step 1: Update Your System
Start by updating your package index and upgrading existing packages:
sudo apt update && sudo apt upgrade -y
Step 2: Install Erlang
RabbitMQ requires Erlang to run. Install Erlang with the following commands:
sudo apt install -y erlang
Step 3: Install RabbitMQ Server
Add the RabbitMQ repository:
echo "deb https://dl.bintray.com/rabbitmq/debian buster main" | sudo tee /etc/apt/sources.list.d/rabbitmq.list
Import the repository signing key:
curl -fsSL https://dl.bintray.com/rabbitmq/keys/rabbitmq-release-signing-key.asc | sudo apt-key add -
Update the package index and install RabbitMQ:
sudo apt update
sudo apt install rabbitmq-server -y
Step 4: Enable RabbitMQ Management Plugin
Enable the management plugin to provide a web-based UI:
sudo rabbitmq-plugins enable rabbitmq_management
Step 5: Start RabbitMQ Server
Start RabbitMQ and enable it to run at boot:
sudo systemctl start rabbitmq-server
sudo systemctl enable rabbitmq-server
Step 6: Configure RabbitMQ Cluster
On each node, edit the RabbitMQ configuration file to allow clustering. Open the configuration file:
sudo nano /etc/rabbitmq/rabbitmq.conf
Add the following lines to configure the cluster:
cluster_formation.peer_discovery_backend = rabbit_peer_discovery_classic_config
cluster_formation.classic_config.nodes.1 = rabbit@NODE1
cluster_formation.classic_config.nodes.2 = rabbit@NODE2
Replace NODE1
and NODE2
with the actual hostnames of your RabbitMQ nodes.
Step 7: Join the Cluster
On the first node, set the cluster name:
sudo rabbitmqctl stop_app
sudo rabbitmqctl reset
sudo rabbitmqctl start_app
On the second node, join the cluster:
sudo rabbitmqctl stop_app
sudo rabbitmqctl join_cluster rabbit@NODE1
sudo rabbitmqctl start_app
Step 8: Access RabbitMQ Management Interface
You can access the RabbitMQ management interface by navigating to http://your_server_ip:15672
in your web browser. Log in with the default credentials:
- Username: guest
- Password: guest
Step 9: Conclusion
You have successfully installed and configured a RabbitMQ cluster on Ubuntu 22.04. This robust messaging system can greatly benefit from being hosted on a Windows VPS. For additional options, explore various VPS UK Windows solutions, including Windows Virtual Private Server Hosting and Windows VPS Hosting UK for optimal performance and reliability.