Help Center/ Elastic Cloud Server/ Best Practices/ Setting Up an Application/ Manually Deploying RabbitMQ (CentOS 7.4)
Updated on 2024-11-04 GMT+08:00

Manually Deploying RabbitMQ (CentOS 7.4)

Overview

The best practices for Huawei Cloud ECS guide you through the manual deployment of RabbitMQ on a Linux ECS. RabbitMQ is a message middleware that uses the Erlang programming language for the Advanced Message Queuing Protocol (AMQP). It originates from the financial system and is used to store and forward messages in the distributed system. Featuring high reliability, scalability, availability, and rich functions, RabbitMQ is widely used.

Prerequisites

The rule listed in the following table has been added to the security group which the target ECS belongs to. For details, see Adding a Security Group Rule.

Table 1 Security group rule

Direction

Priority

Action

Type

Protocol & Port

Source Address

Inbound

1

Allow

IPv4

TCP: 5672

0.0.0.0/0

Inbound

1

Allow

IPv4

TCP: 15672

0.0.0.0/0

Procedure

  1. Install the dependency package and perl.

    1. Log in to the target ECS.
    2. Run the following command to install the dependency packages:

      yum -y install make gcc gcc-c++ m4 ncurses-devel openssl-devel unixODBC-devel

    3. Run the following command to install perl:

      yum install perl

  2. Install Erlang.

    For details, see Erlang Packages Download.
    1. Run the following commands to add Erlang Solutions repository to your system:

      wget https://packages.erlang-solutions.com/erlang-solutions-2.0-1.noarch.rpm

      rpm -Uvh erlang-solutions-2.0-1.noarch.rpm

      Alternatively, add the repository entry manually.

      rpm --import https://packages.erlang-solutions.com/rpm/erlang_solutions.asc

    2. In the /etc/yum.repos.d/ directory, create a file named rabbitmq-erlang.repo, and add the following to the file:

      cd /etc/yum.repos.d/

      vi rabbitmq-erlang.repo
      [erlang-solutions]
      name=CentOS $releasever - $basearch - Erlang Solutions
      baseurl=https://packages.erlang-solutions.com/rpm/centos/$releasever/$basearch
      gpgcheck=1
      gpgkey=https://packages.erlang-solutions.com/rpm/erlang_solutions.asc
      enabled=1

      Press Esc to exit insert mode. Then, enter :wq to save the settings and exit.

    3. Run the following command to install Erlang:

      sudo yum install erlang

      Run the following command to install esl-erlang:

      sudo yum install esl-erlang

    4. Run the following command to check the installation result:

      erl -version

      If information similar to the following is displayed, Erlang has been installed:

      [root@ecs-rabbitmq ~]# erl -version
      Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 11.1.7

  3. Install RabbitMQ.

    1. Run the following command to go to the home directory:

      cd

    2. Perform the following steps to download the RabbitMQ installation package:
      1. Open RabbitMQ.
      2. Click Get Started.
        Figure 1 Get Started
      3. Click Download+Installation.
        Figure 2 Download+Installation
      4. Select a download address based on the ECS OS. Here, the CentOS 7.x is used as an example.
        Figure 3 Selecting a download address
      5. Run the following command to download the RabbitMQ installation package.

        For example, the download address in 3.b.iv is as follows:

        https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.12/rabbitmq-server-3.8.12-1.el7.noarch.rpm

        Run the following command:

        wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.12/rabbitmq-server-3.8.12-1.el7.noarch.rpm

        If the message Unable to establish SSL connection. is displayed during the download,

        you can add --no-check-certificate to the end of the wget command and repeat it for several times for download.

        For example:

        wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.12/rabbitmq-server-3.8.12-1.el7.noarch.rpm --no-check-certificate

      6. Run the following command to install the RabbitMQ installation package:

        yum install rabbitmq-server-3.8.12-1.el7.noarch.rpm

    3. Start the RabbitMQ after it is installed.

      service rabbitmq-server start

    4. Check the RabbitMQ status.

      service rabbitmq-server status

  4. Run the following command to enable the RabbitMQ management web page:

    rabbitmq-plugins enable rabbitmq_management

    Information similar to the following is displayed:

    [root@ecs-rabbitmq ~]# rabbitmq-plugins enable rabbitmq_management
    Enabling plugins on node rabbit@ecs-rabbitmq:
    rabbitmq_management
    The following plugins have been configured:
      rabbitmq_management
      rabbitmq_management_agent
      rabbitmq_web_dispatch
    Applying plugin configuration to rabbit@ecs-2b36...
    The following plugins have been enabled:
      rabbitmq_management
      rabbitmq_management_agent
      rabbitmq_web_dispatch
    
    started 3 plugins.

  5. Run the following command to create a user:

    rabbitmqctl add_user Username password

    For example, run the following command:

    rabbitmqctl add_user root 123456

  6. Run the following command to set the user as the administrator:

    rabbitmqctl set_user_tags Username administrator

    For example, run the following command:

    rabbitmqctl set_user_tags root administrator

  7. Run the following command to assign all permissions to the user:

    rabbitmqctl set_permissions -p / Username '.*' '.*' '.*'

    For example, run the following command:

    rabbitmqctl set_permissions -p / root '.*' '.*' '.*'

  8. Run the following command to start RabbitMQ on the backend:

    rabbitmq-server -detached

  9. Enter http://EIP:15672 in the address bar to access RabbitMQ. If the following page is displayed, RabbitMQ has been installed.

  10. Enter the username and password of the account created in 5 to go to the RabbitMQ management page.