Help Center> Elastic Cloud Server> Best Practices> Manually Deploying RabbitMQ (CentOS 7.4)

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 to which the target ECS belongs. For details, see Adding a Security Group Rule.

Table 1 Security group rule

Transfer Direction

Type

Protocol

Port/Range

Source

Inbound

IPv4

TCP

5672

0.0.0.0/0

Inbound

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 package:

      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.

    1. Run the following command to download the Erlang installation package:

      wget http://erlang.org/download/otp_src_19.3.tar.gz

    2. Run the following command to decompress the package:

      tar xzf otp_src_19.3.tar.gz

      After the decompression, the folder otp_src_19.3 is obtained.

    3. Run the following command to create the erlang folder:

      mkdir /usr/local/erlang

    4. Run the following command to switch to the otp_src_19.3 folder:

      cd otp_src_19.3

    5. Run the following command to check whether the system configuration meets installation requirements:

      ./configure --prefix=/usr/local/erlang --without-javac

    6. Run the following command to compile and install Erlang:

      make && make install

    7. Configure Erlang environment variables.
      1. Run the following command to open the profile configuration file:

        vi /etc/profile

      2. Press i to enter editing mode.
      3. Add the following content to the end of the profile file:
        export PATH=$PATH:/usr/local/erlang/bin
      4. Press Esc to exit the editing mode. Then, enter :wq to save the settings and exit the configuration file.
      5. Run the following command for the environment variables to take effect:

        source /etc/profile

    8. 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 (ASYNC_THREADS,HIPE) (BEAM) emulator version 8.3

  3. Install RabbitMQ.

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

      cd

    2. Run the following commands to download the RabbitMQ installation package:

      wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.9/rabbitmq-server-generic-unix-3.6.9.tar.xz

    3. Run the following command to decompress the package:

      tar xvJf rabbitmq-server-generic-unix-3.6.9.tar.xz

    4. Run the following command to move the decompressed directory to /usr/local/rabbitmq:

      mv rabbitmq_server-3.6.9 /usr/local/rabbitmq

    5. Configure RabbitMQ environment variables.
      1. Run the following command to open the profile configuration file:

        vi /etc/profile

      2. Press i to enter editing mode.
      3. Add the following content to the end of the profile file:
        export PATH=$PATH:/usr/local/rabbitmq/sbin
      4. Press Esc to exit the editing mode. Then, enter :wq to save the settings and exit the configuration file.
      5. Run the following command for the environment variables to take effect:

        source /etc/profile

  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
    The following plugins have been enabled:
      amqp_client
      cowlib
      cowboy
      rabbitmq_web_dispatch
      rabbitmq_management_agent
      rabbitmq_management
    
    Applying plugin configuration to rabbit@ecs-rabbitmq... started 6 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 visit RabbitMQ. If the following page is displayed, RabbitMQ has been installed.

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