Как запустить rabbitmq linux

Содержание
  1. Linux. Установить RabbitMQ
  2. Процесс установки
  3. Установить Erlang
  4. Установить RabbitMQ Server
  5. Активация RabbitMQ сервиса
  6. Создать пользователя с правами администратора
  7. Установить RabbitMQ Web консоль управления
  8. Управление RabbitMQ сервисами
  9. Installing on Debian and Ubuntu
  10. Overview
  11. How to Install Latest RabbitMQ on Debian and Ubuntu
  12. With Apt
  13. Manually Using Dpkg
  14. Supported Distributions
  15. Where to Get Recent Erlang Version on Debian and Ubuntu
  16. Using RabbitMQ Apt Repositories on PackageCloud
  17. PackageCloud Quick Start Script
  18. Enable apt HTTPS Transport
  19. Add Repository Signing Key
  20. Add a Source List File
  21. Distribution
  22. Install Packages
  23. Using RabbitMQ Apt Repositories on Cloudsmith
  24. Cloudsmith Quick Start Script
  25. Install Essential Dependencies
  26. Enable apt HTTPS Transport
  27. Add Repository Signing Keys
  28. Add a Source List File
  29. Distribution
  30. Install Packages
  31. Debian Package Version and Repository Pinning
  32. Manual Installation with Dpkg
  33. User Privilege Requirements
  34. Run RabbitMQ Server
  35. Start the Server
  36. Configuring RabbitMQ
  37. Port Access
  38. Default User Access
  39. Controlling System Limits on Linux
  40. With systemd (Recent Linux Distributions)
  41. With Docker
  42. Verifying the Limit
  43. Managing the Service
  44. Log Files and Management
  45. Log Rotation
  46. Install Erlang from an Apt Repository (PPA) on Launchpad
  47. Modern Erlang on Debian
  48. Install Essential Dependencies
  49. Add Repository Signing Key
  50. Enable apt HTTPS Transport
  51. Add a Source List File
  52. Distribution
  53. Install Erlang Packages
  54. Getting Help and Providing Feedback
  55. Help Us Improve the Docs <3

Linux. Установить RabbitMQ

RabbitMQ является самым популярным брокером сообщений с открытым исходным кодом.
RabbitMQ доступен для большинства популярных операционных систем, поддерживает несколько протоколов обмена сообщениями и его можно легко развернуть на машине с настройкой под различные конфигурации.
Отлично подходит для работы с небольшими так и с крупными высоконагруженными проектами, позволяя манипулировать огромным количеством сообщений, выставляя и забирая сообщения из очередей.

В данной публикации будет описан процесс установки RabbitMQ.
Данный процесс установки должен подходить для таких операционных систем как linuxUbuntu (с 14.04 и старше), Debian (Buster, Stretch, Jessie), Mint (c 14.04 и старше).
Пакет может работать на других дистрибутивах на основе Debian и Ubuntu, если зависимости удовлетворены (например, с помощью репозитория Wheezy backports).

Процесс установки

Установить Erlang

    Первое, что нам потребуется это скачать репозиторий Erlang из официального источника:

И установить Erlang репозиторий в вашу систему:

Выполните обновление пакетов:

Установка Erlang пакета и всех необходимых зависимостей в свою систему:

Установить RabbitMQ Server

После установки зависимостей можно приступить к установке RabbitMQ сервера.

    Теперь необходимо добавить ключ подписи и репозиторий RabbitMQ в систему. Для этого выполните команды:

Выполните команду для обновления пакетов:

Установите RabbitMQ в вашу систему:

Активация RabbitMQ сервиса

После установки RabbitMQ сервера, необходимо активировать его как сервис.
Для этого выполните команды:

Создать пользователя с правами администратора

По умолчанию RabbitMQ создать пользователя с именем — «guest» и паролем — «guest«.
Для полноценной и безопасной работы желательно создать своего нового пользователя — администратора«.

    Добавляем нового пользователя с указанием логина и пароля:

Пример:
Создаем пользователя с логином — «admin» и паролем «password«.

Назначаем пользователю тег администратора:
Назначаю пользователю admin тэг — «administrator«

Назначаем пользователю полные права со всеми привилегиями:

Установить RabbitMQ Web консоль управления

Войти в панель управления можно следующим образом:
Откройте браузер и введите Url вашего проекта и добавьте к нему номер порта:

После перехода по данному адресу вы должны увидеть страницу авторизации в Web панели.

На этом все. RabbitMQ сервер и Web панель управления успешно установлены!

Управление RabbitMQ сервисами

Запуск и остановка сервера с помощью Init:

Запуск и установка сервиса с помощью Systemctl:

Подробную информацию и более полный мануал вы можете посмотреть на официальном сайте RabbitMQ .

Источник

Installing on Debian and Ubuntu

Overview

This guide covers RabbitMQ installation on Debian, Ubuntu and distributions based on one of them.

RabbitMQ is included in standard Debian and Ubuntu repositories. However, the versions included are many releases behind latest RabbitMQ releases. Older distributions, in fact, provide RabbitMQ versions that are already out of support.

Team RabbitMQ produces our own Debian packages and distributes them using Cloudsmith and PackageCloud.

Key sections of this guide are

  • Ways of installing the latest RabbitMQ version on Debian and Ubuntu
  • Supported Ubuntu and Debian distributions
  • Privilege requirements
  • Quick start installation snippet that uses Cloudsmith repositories
  • Quick start installation snippets that uses PackageCloud and Launchpad repositories

Those looking for a more detailed description of the installation steps performed should refer to

  • Manual installation using apt and the Cloudsmith repository
  • Manual installation using apt the PackageCloud and Launchpad repositories

Service management is covered in

More advanced topics include

How to Install Latest RabbitMQ on Debian and Ubuntu

With Apt

There are two options available for installing modern RabbitMQ on Debian and Ubuntu:

  • Option A: using apt repositories on Cloudsmith (quick start script)
  • Option B: using a combination of apt repositories on PackageCloud and Launchpad (quick start script)

Both options will install a modern version of Erlang using Erlang apt repositories on Cloudsmith or Launchpad.

Manually Using Dpkg

Alternatively, the package can be downloaded manually and installed with dpkg -i . This option will require manual installation of all RabbitMQ package dependencies and is highly discouraged.

Supported Distributions

RabbitMQ is supported on several major Debian-based distributions that are still supported by their primary vendor or developer group.

For Debian, this means that RabbitMQ core team focus around package is on the current and prior release of Debian-based distributions, i.e. inline with distribution EOL policy.

Currently the list of supported Debian-based distributions includes

  • Ubuntu 18.04 through 21.04
  • Debian Buster (10), Bullseye (11), and Sid («unstable»)

The package may work on other Debian-based distributions if dependencies are satisfied (e.g. using a backports repository) but their testing and support is done on a best effort basis.

Where to Get Recent Erlang Version on Debian and Ubuntu

RabbitMQ needs Erlang/OTP to run. Erlang/OTP packages in standard Debian and Ubuntu repositories can be significantly out of date and not supported by modern RabbitMQ versions.

Читайте также:  Звук колонки наушники linux

Most recent Erlang/OTP release series are available from a number of alternative apt repositories:

Erlang Release Series Apt Repositories that provide it Notes
24.x
  • Debian packages of Erlang from Team RabbitMQ on Cloudsmith.io
  • Debian packages of Erlang from Team RabbitMQ on Launchpad
  • Erlang Solutions
Supported starting with 3.8.16. See Erlang compatibility guide.
23.x
  • Debian packages of Erlang from Team RabbitMQ on Cloudsmith.io
  • Debian packages of Erlang from Team RabbitMQ on Launchpad
  • Erlang Solutions
Supported starting with 3.8.4. See Erlang compatibility guide.

This guide will focus on the Debian repositories maintained by Team RabbitMQ on Launchpad and on Cloudsmith.io.

Using RabbitMQ Apt Repositories on PackageCloud

Team RabbitMQ maintains an apt repository on PackageCloud, a package hosting service. It provides packages for most recent RabbitMQ releases.

PackageCloud provides repository setup instructions that include a convenient one-liner. Please always inspect scripts that are downloaded from the Internet and executed via a privileged shell!

Note that the PackageCloud script does not currently follow Debian best practices in terms of GPG key handling and the rest of this section does.

This guide will focus on a more traditional and explicit way of setting up an additional apt repository and installing packages.

All steps covered below are mandatory unless otherwise specified.

PackageCloud Quick Start Script

Below is shell snippet that performs those steps. They are documented in more detail below.

Enable apt HTTPS Transport

In order for apt to be able to download RabbitMQ and Erlang packages from services such as PackageCloud, Cloudsmith.io or Launchpad, the apt-transport-https package must be installed:

Add Repository Signing Key

In order for apt to use the repository, RabbitMQ signing key must be available to the system for validation.

See the guide on signatures to learn more.

Add a Source List File

As with all 3rd party apt repositories, a file describing the RabbitMQ and Erlang package repositories must be placed under the /etc/apt/sources.list.d/ directory. /etc/apt/sources.list.d/rabbitmq.list is the recommended location.

The file should have a source (repository) definition line that uses the following pattern:

The next couple of sections discusses what distribution and component values are supported.

Distribution

In order to set up an apt repository that provides the correct package, a few decisions have to be made. One is determining the distribution name. It often matches the Debian or Ubuntu release used:

  • focal for Ubuntu 20.04
  • bionic for Ubuntu 18.04
  • buster for Debian Buster

However, not all distributions are covered (indexed). But there are good news: since the package indexed for these distributions is identical, any reasonably recent distribution name would suffice in practice. For example, users of Debian Buster or Debian Bullseye can both use buster for distribution name.

Below is a table of OS release and distribution names that should be used with the RabbitMQ apt repository on PackageCloud.

Release Distribution
Ubuntu 20.04 focal
Ubuntu 18.04 bionic
Debian Buster buster
Debian Bullseye buster
Debian Sid buster

To add the apt repository to the source list directory ( /etc/apt/sources.list.d ), use:

where $distribution is the name of the Debian or Ubuntu distribution used (see the table above).

So, for example, on Debian Buster it would be

Install Packages

After updating the list of apt sources it is necessary to run apt-get update :

Then install the package with

Using RabbitMQ Apt Repositories on Cloudsmith

Team RabbitMQ maintains two apt repositories on Cloudsmith, a package hosting service. They provide packages for most recent RabbitMQ and modern Erlang releases.

Cloudsmith provides repository setup instructions that include convenient one-liners:

Please always inspect scripts that are downloaded from the Internet and executed via a privileged shell!

This guide will focus on a more traditional and explicit way of setting up additional apt repositories and installing packages.

All steps covered below are mandatory unless otherwise specified.

Cloudsmith Quick Start Script

Below is shell snippet that performs those steps. They are documented in more detail below.

All steps covered below are mandatory unless otherwise specified.

Install Essential Dependencies

Enable apt HTTPS Transport

In order for apt to be able to download RabbitMQ and Erlang packages from services such as PackageCloud, Cloudsmith.io or Launchpad, the apt-transport-https package must be installed:

Add Repository Signing Keys

Cloudsmith signs distributed packages using their own GPG keys, one per repository.

In order to use the repositories, their signing keys must be added to the system. This will enable apt to trust packages signed by that key.

See the guide on signatures to learn more.

Add a Source List File

As with all 3rd party apt repositories, a file describing the RabbitMQ and Erlang package repositories must be placed under the /etc/apt/sources.list.d/ directory. /etc/apt/sources.list.d/rabbitmq.list is the recommended location.

The file should have a source (repository) definition line that uses the following pattern:

The next couple of sections discusses what distribution and component values are supported.

Distribution

In order to set up an apt repository that provides the correct package, a few decisions have to be made. One is determining the distribution name. It often matches the Debian or Ubuntu release used:

  • focal for Ubuntu 20.04
  • bionic for Ubuntu 18.04
  • buster for Debian Buster

However, not all distributions are covered (indexed). But there are good news: since the package indexed for these distributions is identical, any reasonably recent distribution name would suffice in practice. For example, users of Debian Buster or Debian Bullseye can both use buster for distribution name.

Below is a table of OS release and distribution names that should be used with the RabbitMQ apt repository on PackageCloud.

Release Distribution
Ubuntu 20.04 focal
Ubuntu 18.04 bionic
Debian Buster buster
Debian Bullseye buster
Debian Sid buster

To add the apt repository to the source list directory ( /etc/apt/sources.list.d ), use:

where $distribution is the name of the Debian or Ubuntu distribution used (see the table above).

For example, on Debian Buster it would be

Install Packages

After updating the list of apt sources it is necessary to run apt-get update :

Then install the package with

Debian Package Version and Repository Pinning

Version pinning is an optional step. If not used, apt will install the most recent version available.

When the same package (e.g. erlang-base ) is available from multiple apt repositories operators need to have a way to indicate what repository should be preferred. It may also be desired to restrict Erlang version to avoid undesired upgrades. apt package pinning feature can be used to address both problems.

Package pinning is configured with a file placed under the /etc/apt/preferences.d/ directory, e.g. /etc/apt/preferences.d/erlang . After updating apt preferences it is necessary to run apt-get update :

The following preference file example will configure apt to install erlang-* packages from Cloudsmith.io and not standard Debian or Ubuntu repository:

The following is similar to the example above but prefers Launchpad:

Effective package pinning policy can be verified with

The following preference file example will pin all erlang-* packages to 23.3 (assuming package epoch for the package is 1):

The following preference file example will pin rabbitmq-server package to 3.9.7 (assuming package epoch for the package is 1):

In the example below, the esl-erlang package is pinned to 23.3.1 (assuming package epoch for the package is 1):

Manual Installation with Dpkg

In some cases it may be easier to download the package directly from GitHub and install it manually using sudo dpkg -i . Below is a download link.

Description Download Signature
.deb for Debian-based Linux (from GitHub) rabbitmq-server_3.9.7-1_all.deb Signature

When installing manually with dpkg , it is necessary to install package dependencies first. dpkg , unlike apt , does not resolve or manage dependencies.

Here’s an example that does that, installs wget , downloads the RabbitMQ package and installs it:

Installation via apt repositories is recommended over downloading the package directly and installing via dpkg -i . When the RabbitMQ package is installed manually with dpkg -i the operator is responsible for making sure that all package dependencies are met.

User Privilege Requirements

RabbitMQ Debian package will require sudo privileges to install and manage. In environments where sudo isn’t available, consider using the generic binary build instead.

Run RabbitMQ Server

Start the Server

The server is started as a daemon by default when the RabbitMQ server package is installed. It will run as a non-privileged user rabbitmq .

As an administrator, start and stop the server as usual for Debian-based systems:

Configuring RabbitMQ

On most systems, a node should be able to start and run with all defaults. Please refer to the Configuration guide to learn more and Production Checklist for guidelines beyond development environments.

Note: the node is set up to run as system user rabbitmq . If location of the node database or the logs is changed, the files and directories must be owned by this user.

Port Access

RabbitMQ nodes bind to ports (open server TCP sockets) in order to accept client and CLI tool connections. Other processes and tools such as SELinux may prevent RabbitMQ from binding to a port. When that happens, the node will fail to start.

CLI tools, client libraries and RabbitMQ nodes also open connections (client TCP sockets). Firewalls can prevent nodes and CLI tools from communicating with each other. Make sure the following ports are accessible:

  • 4369: epmd, a peer discovery service used by RabbitMQ nodes and CLI tools
  • 5672, 5671: used by AMQP 0-9-1 and 1.0 clients without and with TLS
  • 25672: used for inter-node and CLI tools communication (Erlang distribution server port) and is allocated from a dynamic range (limited to a single port by default, computed as AMQP port + 20000). Unless external connections on these ports are really necessary (e.g. the cluster uses federation or CLI tools are used on machines outside the subnet), these ports should not be publicly exposed. See networking guide for details.
  • 35672-35682: used by CLI tools (Erlang distribution client ports) for communication with nodes and is allocated from a dynamic range (computed as server distribution port + 10000 through server distribution port + 10010). See networking guide for details.
  • 15672: HTTP API clients, management UI and rabbitmqadmin (only if the management plugin is enabled)
  • 61613, 61614: STOMP clients without and with TLS (only if the STOMP plugin is enabled)
  • 1883, 8883: MQTT clients without and with TLS, if the MQTT plugin is enabled
  • 15674: STOMP-over-WebSockets clients (only if the Web STOMP plugin is enabled)
  • 15675: MQTT-over-WebSockets clients (only if the Web MQTT plugin is enabled)
  • 15692: Prometheus metrics (only if the Prometheus plugin is enabled)

Default User Access

The broker creates a user guest with password guest . Unconfigured clients will in general use these credentials. By default, these credentials can only be used when connecting to the broker as localhost so you will need to take action before connecting from any other machine.

See the documentation on access control for information on how to create more users and delete the guest user.

Controlling System Limits on Linux

RabbitMQ installations running production workloads may need system limits and kernel parameters tuning in order to handle a decent number of concurrent connections and queues. The main setting that needs adjustment is the max number of open files, also known as ulimit -n . The default value on many operating systems is too low for a messaging broker ( 1024 on several Linux distributions). We recommend allowing for at least 65536 file descriptors for user rabbitmq in production environments. 4096 should be sufficient for many development workloads.

There are two limits in play: the maximum number of open files the OS kernel allows ( fs.file-max ) and the per-user limit ( ulimit -n ). The former must be higher than the latter.

With systemd (Recent Linux Distributions)

On distributions that use systemd, the OS limits are controlled via a configuration file at /etc/systemd/system/rabbitmq-server.service.d/limits.conf . For example, to set the max open file handle limit ( nofile ) to 64000 :

See systemd documentation to learn about the supported limits and other directives.

With Docker

To configure kernel limits for Docker contains, use the «default-ulimits» key in Docker daemon configuration file. The file has to be installed on Docker hosts at /etc/docker/daemon.json :

Verifying the Limit

RabbitMQ management UI displays the number of file descriptors available for it to use on the Overview tab.

includes the same value.

The following command

can be used to display effective limits of a running process. $RABBITMQ_BEAM_PROCESS_PID is the OS PID of the Erlang VM running RabbitMQ, as returned by rabbitmqctl status .

Managing the Service

To start and stop the server, use the systemctl tool. The service name is rabbitmq-server :

systemctl status rabbitmq-server will report service status as observed by systemd (or similar service manager):

It will produce output similar to this:

rabbitmqctl , rabbitmq-diagnostics , and other CLI tools will be available in PATH and can be invoked by a sudo -enabled user:

All rabbitmqctl commands will report an error if no node is running. See the CLI tools and Monitoring guides to learn more.

Log Files and Management

Server logs can be found under the configurable directory, which usually defaults to /var/log/rabbitmq when RabbitMQ is installed via a Linux package manager.

RABBITMQ_LOG_BASE can be used to override log directory location.

Assuming a systemd -based distribution, system service logs can be inspected using

which requires superuser privileges. Its output can be filtered to narrow it down to RabbitMQ-specific entries:

The output will look similar to this:

Log Rotation

The broker always appends to the log files, so a complete log history is retained.

logrotate is the recommended way of log file rotation and compression. By default, the package will set up logrotate to run weekly on files located in default /var/log/rabbitmq directory. Rotation configuration can be found in /etc/logrotate.d/rabbitmq-server .

Install Erlang from an Apt Repository (PPA) on Launchpad

This additional section covers installation of modern Erlang packages from Launchpad. To install modern Erlang and RabbitMQ, please refer to the sections above:

Modern Erlang on Debian

Standard Debian and Ubuntu repositories tend to provide outdated versions of Erlang/OTP. Team RabbitMQ maintains an apt repository that includes packages of latest Erlang/OTP releases on Launchpad.

RabbitMQ core team focus around package is on the current and prior release of Debian-based distributions, i.e. inline with distribution EOL policy.

The repository currently supports the following Ubuntu distributions:

  • Ubuntu 20.04 (Focal)
  • Ubuntu 18.04 (Bionic)

The following Debian releases can currently use the same apt repository:

  • Debian 10 (Buster)
  • Debian 11 (Bullseye)

The repo currently provides most recent patch releases in the following Erlang series:

In order to use the repository, it is necessary to

  • Install prerequisites needed to download signing keys and packages over HTTPS
  • Add repository signing key to your system. apt will verify package signatures during installation.
  • Add a source list file for the repository
  • Update package metadata
  • Install Erlang packages required by RabbitMQ

Install Essential Dependencies

Add Repository Signing Key

In order to use the repository, add RabbitMQ signing key to the system. This will enable apt to trust packages signed by that key.

See the guide on signatures to learn more.

Enable apt HTTPS Transport

In order for apt to be able to download RabbitMQ and Erlang packages from services such as PackageCloud, Cloudsmith.io or Launchpad, the apt-transport-https package must be installed:

Add a Source List File

As with all 3rd party Apt (Debian) repositories, a file describing the repository must be placed under the /etc/apt/sources.list.d/ directory. /etc/apt/sources.list.d/erlang.list is the recommended location.

The file should have a source (repository) definition line that uses the following pattern:

The next section discusses what distribution values are supported by the Launchpad PPA.

Distribution

In order to set up an apt repository that provides the correct package, a few decisions have to be made. One is determining the distribution name. It typically matches the Debian or Ubuntu release used but only a handful of distributions are supported (indexed) by the Erlang Debian packages maintained by Team RabbitMQ:

  • focal for Ubuntu 20.04
  • bionic for Ubuntu 18.04
  • bionic for Debian Buster and later versions

However, not all distributions are covered (indexed). But there are good news: since the package indexed for these distributions is identical, any reasonably recent distribution name would suffice in practice. For example, users of Debian Buster, Debian Sid, Ubuntu Disco and Ubuntu Eoan can use both stretch and bionic for distribution name.

Below is a table of OS release and distribution names that should be used with the Launchpad repository.

Release Distribution Name
Ubuntu 20.04 focal
Ubuntu 18.04 bionic
Debian Buster bionic
Debian Bullseye bionic
Debian Sid bionic

Install Erlang Packages

After updating the list of apt sources it is necessary to run apt-get update :

Then packages can be installed just like with the standard Debian repositories:

Getting Help and Providing Feedback

If you have questions about the contents of this guide or any other topic related to RabbitMQ, don’t hesitate to ask them on the RabbitMQ mailing list.

Help Us Improve the Docs <3

If you’d like to contribute an improvement to the site, its source is available on GitHub. Simply fork the repository and submit a pull request. Thank you!

Источник

Читайте также:  Как разграничить права пользователей windows 10
Оцените статью