Rabbitmq install and management

Introduction

Any experienced system administrator knows that sometimes putting off tasks for later is very useful and even necessary, especially if the task is time-consuming and consumes a lot of resources. To do this, you need a message broker – a program that receives messages (tasks) from various senders (web applications), forms a queue from them, and then distributes them between work processes.

This article will focus on the RabbitMQ project – a bunch of open applications for implementing the functions of a message broker that implements the Advanced Message Queuing Protocol (AMQP).

Messages, message brokers and sequence

Messaging is a way of exchanging certain data between processes, applications, virtual and physical servers. These messages, which perform some computational functions, can contain almost anything, from plain text to large blocks of binary data. For the correct execution of this process, a third-party program is needed – this is the message broker.

A message broker is usually a group of applications, each individual component of which is designed to process a certain stage of messaging: to receive a message, define it in the queue, and transfer the message to the work process responsible for its execution. Often, instead of full-fledged solutions, programs are used that were not originally intended for this work (databases, cron daemon, etc.); they simply create a message queue (which technically represents infinite buffers), and then pass them for automatic processing or for polling.

Why do you need message broker?

Message brokers act as an intermediary between various services (web applications). They significantly reduce the load and shorten the delivery time of messages, since tasks that take some time to be processed are distributed between workflows designed exclusively to perform these tasks. They provide a reliable channel for transmitting messages from one application to another.

When do you need message broker?

In general, the basic functionality of message brokers covers many areas, including, but not limited to:

  • Reducing the response time of web servers to requests (because they do not have to perform resource-intensive tasks).
  • Distribution of the message to several recipients (for example, for processing).
  • Offline users can later retrieve all the data.
  • Completely asynchronous mode of operation with server systems.
  • Ordering and prioritization of tasks;
  • Load balancing between work processes.
  • Improving the reliability and uptime of the application.
  • And much more.

A short review of RabbitMQ

RabbitMQ (released in 2007) is one of the most popular open-source message brokers licensed under the Mozilla Public License v1.1 as an implementation of the Advanced Message Queuing Protocol. Designed in Erlang, RabbitMQ is fairly easy to use and install.

Who RabbitMQ work?

RabbitMQ provides an interface that connects senders (Publishers) with recipients (Consumers) using a broker that distributes the data in the appropriate lists – Message Queues.

APPLICATION       EXCHANGE        TASK LIST        WORKER
[DATA] -------> [DATA] ---> [D]+[D][D][D] --->  [DATA]
Publisher        EXCHANGE          Queue         Consumer

Benefits of RabbitMQ

Unlike other solutions, RabbitMQ is a full-fledged application stack, and not a simple base for the application of your choice. It provides all the necessary tools in the complex.

A short review of AMQP

AMQP (Advanced Message Queuing Protocol) is a widespread open standard for the distribution and transmission of messages. As a protocol and standard, it establishes a common framework for the interaction of various applications and message brokers and eliminates the problems caused by individual program design.

RabbitMQ installation

RabbitMQ packages are provided by CentOS / RHEL and Ubuntu / Debian. But, as a rule, such packages are outdated. Therefore, it is recommended to download and install RabbitMQ manually.

Note: It is recommended that all manual actions be performed on a fresh server so as not to disrupt the operation of previously launched applications and not cause a configuration failure.

Install RabbitMQ in CentOS/RHEL

Before you begin installing RabbitMQ, you need to install the program dependencies, one of which is Erlang. However, first of all, it is necessary to update the system and standard applications; to do this, run:

yum -y update

For Erlang installation you can use:

# Add and enable relevant application repositories:
# Note: We are also enabling third party remi package repositories.
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
# Finally, download and install Erlang:
yum install -y erlang

now you can install RabbitMQ:

# Download the latest RabbitMQ package using wget:
wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.2.2/rabbitmq-server-3.2.2-1.noarch.rpm
# Add the necessary keys for verification:
rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc
# Install the .RPM package using YUM:
yum install rabbitmq-server-3.2.2-1.noarch.rpm

Установка RabbitMQ в Ubuntu 18.04/Debian 9

The installation process of RabbitMQ in Ubuntu/Debian almost the same in on CentOS.

First, you need to update software:

apt-get    update
apt-get -y upgrade

Add rabbitmq key:

curl -fsSL https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc | sudo apt-key add -

Do package update:

apt-get update

Now you can install rabbitmq RabbitMQ:

sudo apt-get install rabbitmq-server

RabbitMQ Management

As mentioned earlier, the RabbitMQ broker is very easy to use. This section provides instructions for managing and configuring RabbitMQ.

Enabling the management console

The RabbitMQ Management Console (RabbitMQ Management Console) is one of the available plug-ins that allows you to monitor the processes of the RabbitMQ server through a graphical web-based user interface.

Using this console, you can

  • Manage messaging, message queues, connections, and users;
  • Track message queues, connections, and message rates
  • Send and receive messages;
  • Track Erlang processes and memory usage;
  • And much more.

To enable RabbitMQ management run the command:

sudo rabbitmq-plugins enable rabbitmq_management

Now you can open management console in browser visiting your_ip:15672.

Default rabbitmq user – guest.

Default rabbitmq password – guest

RabbitMQ management in CentOS/RHEL

To enable RabbitMQ autostart you need to run:

chkconfig rabbitmq-server on

To start, stop, restart, and check status use commands below:

# start:
/sbin/service rabbitmq-server start
# stop:
/sbin/service rabbitmq-server stop
# restart:
/sbin/service rabbitmq-server restart
# status:
/sbin/service rabbitmq-server status

RabbitMQ management in Ubuntu/Debian

To start, stop, restart, and check rabbitmq status on Ubuntu/Debian use commands below:

# Запуск:
service rabbitmq-server start
# stop:
service rabbitmq-server stop
# restart:
service rabbitmq-server restart
# status:
service rabbitmq-server status

Now your rabbitmq server is ready to use!

RabbitMQ configuration

RabbitMQ поставляется со стандартными настройками. В целом, они довольно надёжны инее требуют редактирования.

Configure RabbitMQ

RabbitMQ comes with standard settings. In general, they are quite reliable and require editing.

For information on customizing RabbitMQ, refer to the official documentation.

Reference for ubuntu installation: https://www.rabbitmq.com/install-debian.html

Reference for CentOS installation: https://www.rabbitmq.com/install-rpm.html

Also, You can read more Linux guides by link You can read more Linux guides by link https://linuxnotes.org/category/linux-how-to/

Viva La Linux!

Leave A Comment