How to Install RabbitMQ on CentOS 7

小灰灰 2022-01-15 16:19 318阅读 0赞

RabbitMQ is a widely used open-source message broker written in the Erlang programming language. As a message-oriented middleware, RabbitMQ can be used to implement the Advanced Message Queuing Protocol (AMQP) on all modern operating systems.

This article explains how to install RabbitMQ on a Vultr CentOS 7 server instance.

Prerequisites

Before getting started, you need to:

  • Deploy a brand new Vultr CentOS 7 server instance.
  • Log into the server as a non-root user with sudo privileges. You can learn about how to create such a sudo user in this Vultr article.

Step 1: Update the system

Use the following commands to update your CentOS 7 system to the latest stable status:

  1. sudo yum install epel-release
  2. sudo yum update
  3. sudo reboot

Step 2: Install Erlang

Since RabbitMQ is written in Erlang, you need to install Erlang before you can use RabbitMQ:

  1. cd ~
  2. wget http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
  3. sudo rpm -Uvh erlang-solutions-1.0-1.noarch.rpm
  4. sudo yum install erlang

Verify your installation of Erlang:

  1. erl

You will be brought into the Erlang shell which resembles:

  1. Erlang/OTP 18 [erts-7.3] [source-d2a6d81] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]
  2. Eshell V7.3 (abort with ^G)
  3. 1>

Press Ctrl+C twice to quit the Erlang shell.

Step 3: Install RabbitMQ

Use the following commands to install the latest version of RabbitMQ which is 3.6.1 at the time of writing:

  1. cd ~
  2. wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.1/rabbitmq-server-3.6.1-1.noarch.rpm
  3. sudo rpm --import https://www.rabbitmq.com/rabbitmq-signing-key-public.asc
  4. sudo yum install rabbitmq-server-3.6.1-1.noarch.rpm

Step 4: Modify firewall rules

In order to access the RabbitMQ remote management console, you need to allow inbound TCP traffic on ports 4369, 25672, 5671, 5672, 15672, 61613, 61614, 1883, and 8883.

  1. sudo firewall-cmd --zone=public --permanent --add-port=4369/tcp --add-port=25672/tcp --add-port=5671-5672/tcp --add-port=15672/tcp --add-port=61613-61614/tcp --add-port=1883/tcp --add-port=8883/tcp
  2. sudo firewall-cmd --reload

Start the RabbitMQ server and enable it to start on system boot:

  1. sudo systemctl start rabbitmq-server.service
  2. sudo systemctl enable rabbitmq-server.service

You can check the status of RabbitMQ with:

  1. sudo rabbitmqctl status

Step 5: Enable and use the RabbitMQ management console

Enable the RabbitMQ management console so that you can monitor the RabbitMQ server processes from a web browser:

  1. sudo rabbitmq-plugins enable rabbitmq_management
  2. sudo chown -R rabbitmq:rabbitmq /var/lib/rabbitmq/

Next, you need to setup an administrator user account for accessing the RabbitMQ server management console. In the following commands, “mqadmin” is the administrator’s username, “mqadminpassword” is the password. Remember to replace them with your own ones.

  1. sudo rabbitmqctl add_user mqadmin mqadminpassword
  2. sudo rabbitmqctl set_user_tags mqadmin administrator
  3. sudo rabbitmqctl set_permissions -p / mqadmin ".*" ".*" ".*"

Now, visit the following URL:

  1. http://[your-vultr-server-IP]:15672/

Log in with the credentials you had specified earlier. You will be greeted with the RabbitMQ remote management console, where you can learn more about RabbitMQ. Enjoy!

发表评论

表情:
评论列表 (有 0 条评论,318人围观)

还没有评论,来说两句吧...

相关阅读