RabbitMQ is an open source message broker that implements the Advanced Message Queuing Protocol (AMQP) to store and forward messages in a distributed system. RabbitMQ is easy to use, scalable, and highly available. This topic describes how to deploy RabbitMQ on an Elastic Compute Service (ECS) instance.
Prerequisites
A security group of the Virtual Private Cloud (VPC) type is created. An inbound rule that allows traffic on ports 80, 5672, and 15672 is added to the security group. If you want to connect to a Linux instance in the security group by using SSH, configure the rule to allow traffic on port 22. For more information, see Add a security group rule.
Background information
The RabbitMQ server is written in the Erlang programming language. RabbitMQ supports multiple types of clients such as Python, Ruby, .NET, Java, Java Message Service (JMS), C, Hypertext Preprocessor (PHP), ActionScript, Extensible Messaging and Presence Protocol (XMPP), Streaming Text Oriented Messaging Protocol (STOMP), and Asynchronous JavaScript and XML (AJAX).
Manually deploy RabbitMQ. This method is suitable for users who have a basic knowledge of Linux commands and can perform custom deployment. Use the following operating system and software versions to manually deploy RabbitMQ:
Operating system: CentOS 7.8 64-bit public image
RabbitMQ: RabbitMQ 3.7.8
Erlang: Erlang 21.1
JDK: JDK 1.8.0_282
Manually deploy RabbitMQ
Create and connect to a Linux instance.
Create a Linux instance.
For more information, see Create an instance on the Custom Launch tab. When you configure parameters for the instance, take note of the following items:
Select Assign Public IPv4 Address for the Public IP Address parameter.
Select the security group configured in the "Prerequisites" section.
Complete other settings.
Connect to the instance.
For more information, see Connect to a Linux instance by using a password or key.
Install Erlang.
Run the following command to install the dependency for Erlang:
sudo yum install -y make gcc gcc-c++ m4 openssl openssl-devel ncurses-devel unixODBC unixODBC-devel java java-devel
Run the following command to download the Erlang installation package:
wget http://erlang.org/download/otp_src_21.1.tar.gz
Run the following command to decompress the Erlang installation package:
tar -zxvf otp_src_21.1.tar.gz
Run the following commands to go to the path to which the Erlang installation package is decompressed and create a directory for Erlang:
cd otp_src_21.1 sudo mkdir -p /usr/local/erlang
Run the following commands in sequence to compile and install Erlang:
sudo ./configure --prefix=/usr/local/erlang sudo make && make install
After Erlang is installed, run the following command to configure the environment variable for Erlang:
sudo echo 'export PATH=$PATH:/usr/local/erlang/bin' >> /etc/profile
Run the following command to apply the configured environment variable:
sudo source /etc/profile
Run the following commands to go back to the /root directory. View the Erlang version to check whether Erlang is installed.
cd erl -version
A command output similar to the following one indicates that Erlang is installed.
Download and install RabbitMQ.
Different RabbitMQ versions are compatible with different Erlang versions. For more information, see RabbitMQ Erlang Version Requirements. In this example, Erlang 21.1 is used. In this case, you must download RabbitMQ 3.6.9.
Run the following command to download the RabbitMQ installation package:
wget https://github.com/rabbitmq/rabbitmq-server/releases/download/rabbitmq_v3_6_9/rabbitmq-server-3.6.9-1.el7.noarch.rpm
Run the following command to install RabbitMQ:
cd yum install -y rabbitmq-server-3.6.9-1.el7.noarch.rpm
Configure RabbitMQ.
Run the following commands in sequence to configure RabbitMQ to run on system startup and start RabbitMQ:
systemctl enable rabbitmq-server systemctl start rabbitmq-server
To ensure data security, we recommend that you run the following command to delete the default user of RabbitMQ.
The default username and password of RabbitMQ are both
guest
.sudo rabbitmqctl delete_user guest
Create a RabbitMQ administrator user.
Run the following command to create a user:
sudo rabbitmqctl add_user <Username> <Password>
Specify the <Username> and <Password> parameters.
Run the following command to set the new user as an administrator:
sudo rabbitmqctl set_user_tags <Username> administrator
Run the following command to grant all permissions to the new user:
sudo rabbitmqctl set_permissions -p / <Username> ".*" ".*" ".*"
Run the following command to start the web management interface of RabbitMQ:
rabbitmq-plugins enable rabbitmq_management
On your computer, use a browser to access
http://<Public IP address of the Linux instance>:15672
.The following page indicates that RabbitMQ is installed.
Enter the username and password of the RabbitMQ administrator user that you created and click Login to access the RabbitMQ management interface.
The RabbitMQ management interface appears, as shown in the following figure.