Deploy open-source RabbitMQ
RabbitMQ is an open-source message broker that supports AMQP, MQTT, STOMP, and HTTP/WebSockets for reliable asynchronous messaging in distributed systems with high availability and fault tolerance. You can deploy RabbitMQ on an ECS instance by using manual installation, a Marketplace image, or Terraform.
Deploy RabbitMQ
-
Manual deployment: Install and configure RabbitMQ step by step. Requires basic Linux knowledge.
-
Quick deployment: Use a Marketplace image or Terraform to automate installation and reduce deployment time.
Manual deployment
The following steps apply to the latest RabbitMQ version. For other versions and methods, visit Installing RabbitMQ.
Prerequisites
Your ECS instance must meet the following requirements:
-
The instance has a public IP address or an Elastic IP Address (EIP).
-
Operating system: Ubuntu 20.04, Ubuntu 22.04, or Debian 11.0 to Debian 12.5.
For all supported operating systems, visit Installing RabbitMQ.
-
Security group rules: Add inbound rules to the security group to allow traffic on ports 22, 80, and 15672.
NoteTo connect to RabbitMQ with an MQ tool, also allow traffic on port 5672.
Procedure
-
Connect to the instance where you will deploy RabbitMQ.
-
Install RabbitMQ.
-
Install RabbitMQ dependencies.
sudo apt-get install curl gnupg apt-transport-https -y -
Add the GPG public keys for RabbitMQ and Erlang to the system keyring.
curl -1sLf "https://keys.openpgp.org/vks/v1/by-fingerprint/0A9AF2115F4687BD29803A206B73A36E6026DFCA" | sudo gpg --dearmor | sudo tee /usr/share/keyrings/com.rabbitmq.team.gpg > /dev/null curl -1sLf https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-erlang.E495BB49CC4BBE5B.key | sudo gpg --dearmor | sudo tee /usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg > /dev/null curl -1sLf https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-server.9F4587F226208342.key | sudo gpg --dearmor | sudo tee /usr/share/keyrings/rabbitmq.9F4587F226208342.gpg > /dev/null -
Add the RabbitMQ and Erlang APT repositories to
/etc/apt/sources.list.d/rabbitmq.list.sudo tee /etc/apt/sources.list.d/rabbitmq.list <<EOF deb [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] https://ppa1.novemberain.com/rabbitmq/rabbitmq-erlang/deb/ubuntu jammy main deb-src [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] https://ppa1.novemberain.com/rabbitmq/rabbitmq-erlang/deb/ubuntu jammy main deb [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] https://ppa2.novemberain.com/rabbitmq/rabbitmq-erlang/deb/ubuntu jammy main deb-src [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] https://ppa2.novemberain.com/rabbitmq/rabbitmq-erlang/deb/ubuntu jammy main deb [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] https://ppa1.novemberain.com/rabbitmq/rabbitmq-server/deb/ubuntu jammy main deb-src [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] https://ppa1.novemberain.com/rabbitmq/rabbitmq-server/deb/ubuntu jammy main deb [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] https://ppa2.novemberain.com/rabbitmq/rabbitmq-server/deb/ubuntu jammy main deb-src [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] https://ppa2.novemberain.com/rabbitmq/rabbitmq-server/deb/ubuntu jammy main EOF -
Update the local package index.
sudo apt-get update -y -
Install Erlang packages.
sudo apt-get install -y erlang-base \ erlang-asn1 erlang-crypto erlang-eldap erlang-ftp erlang-inets \ erlang-mnesia erlang-os-mon erlang-parsetools erlang-public-key \ erlang-runtime-tools erlang-snmp erlang-ssl \ erlang-syntax-tools erlang-tftp erlang-tools erlang-xmerl -
Install RabbitMQ.
sudo apt-get install rabbitmq-server -y --fix-missing
-
-
Configure RabbitMQ.
-
Enable and start the RabbitMQ service.
sudo systemctl enable rabbitmq-server sudo systemctl start rabbitmq-server -
Delete the default user for security.
The default username and password for RabbitMQ are both
guest.sudo rabbitmqctl delete_user guest -
Create a RabbitMQ administrator.
-
Create a user.
sudo rabbitmqctl add_user <username> <password>Replace
<username>and<password>with your credentials. -
Assign the administrator tag to the user.
sudo rabbitmqctl set_user_tags <username> administrator -
Grant all permissions to the user.
sudo rabbitmqctl set_permissions -p / <username> ".*" ".*" ".*"
-
-
-
Enable the RabbitMQ management plugin.
sudo rabbitmq-plugins enable rabbitmq_management
Quick deployment
Marketplace image
A Marketplace image automates installation and configuration. Image pricing is listed on the product details page.
-
Click Open-source message queue middleware RabbitMQ or to go to the image details page.
The image details page provides image specifications and deployment instructions.
-
Click Immediately Buy or .
-
On the Custom Launch page, configure the parameters and purchase the ECS instance as prompted.
Set the following key parameters. All parameters are described in Create an instance on the Custom Launch tab.
-
Image: The Image section is already set to the image that you purchased.
-
Public IP: Select Assign Public IPv4 Address.
-
Security Group: Allow inbound traffic on ports 22, 80, and 15672.
-
-
Retrieve the RabbitMQ credentials.
-
Connect to the RabbitMQ server.
-
Run the following command to retrieve the RabbitMQ credentials.
sudo cat /credentials/password.txtExample output:
-
rabbitmq_user: Username.
-
rabbitmq_password: Password.
-
rabbitmq_gui_port: Web management port.
-
rabbitmq_mq_port: Remote connection port.
-
rabbitmq_er_port: Erlang inter-process communication port.
-
rabbitmq_mqtt_port: MQTT service port.
root@iZuf660jbfxxx:~# sudo cat /credentials/password.txt ======== credentials for rabbitmq ======== rabbitmq_user: admin rabbitmq_password: OOhWmVE9xxx rabbitmq_gui_port: 15672 rabbitmq_mq_port: 5672 rabbitmq_er_port: 4369 rabbitmq_mqtt_port: 1833 -
-
Terraform
Terraform is an Infrastructure as Code (IaC) tool that automates cloud resource provisioning through declarative configuration files.
Procedure
-
Click Run with one click or to open Terraform Explorer and automatically load the Terraform code.
-
Modify the parameters as needed. By default, one VPC, one vSwitch, one security group, and one pay-as-you-go ECS instance are created in the cn-beijing region. ECS instance pricing is described in Billing overview.
-
Click Initiate Debugging to preview resources. If correct, click Plan & Apply to deploy.
Log in to the RabbitMQ console
-
In the address bar of your browser, enter
http://<your_instance_public_ip>:15672.On the RabbitMQ Management login page, enter your credentials and click Login.
-
After you click Login, the RabbitMQ management interface opens.
The Overview tab displays RabbitMQ and Erlang versions, node resource usage, and connection and queue statistics, confirming that RabbitMQ is running correctly.
Migrate open-source RabbitMQ to the cloud
To resolve stability issues such as message backlogs and split-brain problems, and to gain high concurrency and elastic scaling, migrate your self-managed RabbitMQ cluster to ApsaraMQ for RabbitMQ. Migrate open-source RabbitMQ to the cloud.