[RabbitMQ in action] 01 Install RabbitMQ on Linux in 3 minutes

This section uses docker to install RabbitMQ. The image used is bitnami. Bitnami is a company that provides Docker images and software packages for various popular applications. Using docker, we can run the program we want to install in 3 minutes. I have to say it’s really convenient. Okay, let’s get started. Prerequisites for use: Linux virtual machine and docker environment installed. If docker is not installed, please refer here to install docker first.

1. Search for images

[root@localhost ~]# docker search rabbitmq
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
rabbitmq RabbitMQ is an open source multi-protocol me… 4887 [OK]
bitnami/rabbitmq Bitnami Docker Image for RabbitMQ 103 [OK]

Here we choosebitname/rabbitmq

2. Download the image

[root@localhost ~]# docker pull bitnami/rabbitmq
Using default tag: latest
latest: Pulling from bitnami/rabbitmq

3. Run the RabbitMQ image

docker run -d --name rabbitmq \
-e RABBITMQ_USERNAME=admin \
-e RABBITMQ_PASSWORD=admin \
-p 15672:15672 -p 5672:5672 -p 25672:25672 -p 61613:61613 -p 1883:1883 bitnami/rabbitmq

where RABBITMQ_USERNAME is the username
RABBITMQ_PASSWORD is the password
For more descriptions of environment variables, see the end of the article

4. Check the running effect

Check to see if the docker container has started successfully. You can see it is running below.

[root@localhost ~]# docker ps | grep rabbit
0d5cb60e3a06 bitnami/rabbitmq "/opt/bitnami/script…" 22 seconds ago Up 20 seconds 4369/tcp, 5551-5552/tcp, 0.0.0.0:1883->1883/tcp, :::1883->1883/ tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, :::5672->5672/tcp, 0.0.0.0:15672->15672/tcp, :::15672->15672/tcp, 0.0. 0.0:25672->25672/tcp, :::25672->25672/tcp, 0.0.0.0:61613->61613/tcp, :::61613->61613/tcp, 15671/tcp rabbitmq

Enter the address to access the console
http://192.168.56.201:15672/#/
Username: admin, password admin
login successful

At this point, we can happily play with RabbitMQ

5. Description of environment variables

(Sourced from official website)

RABBITMQ_VHOST: RabbitMQ application vhost. Default: /
RABBITMQ_VHOSTS: List of additional virtual host (vhost), separated by space. E.g.: /shared /prioritized /tasks
RABBITMQ_USERNAME: RabbitMQ application username. Default: user
RABBITMQ_PASSWORD: RabbitMQ application password. Default: bitnami
RABBITMQ_SECURE_PASSWORD: Whether to set the RabbitMQ password securely. This is incompatible with loading external RabbitMQ definitions. Default: no
RABBITMQ_LOAD_DEFINITIONS: Whether to load external RabbitMQ definitions. This is incompatible with setting the RabbitMQ password securely. Default: no.
RABBITMQ_ERL_COOKIE: Erlang cookie to determine whether different nodes are allowed to communicate with each other.
RABBITMQ_NODE_TYPE: Node Type. Valid values: stats, queue-ram or queue-disc. Default: stats
RABBITMQ_NODE_NAME: Node name and host. E.g.: node@hostname or node (localhost won't work in cluster topology). Default rabbit@localhost. If using this variable, ensure that you specify a valid host name as the container wil fail to start otherwise. If using a fully qualified domain name, RABBITMQ_USE_LONGNAME needs to be set to true as well.
RABBITMQ_USE_LONGNAME: When set to true this will cause RabbitMQ to use fully qualified names to identify nodes. Default: false
RABBITMQ_FORCE_BOOT: Force a node to start even if it was not the last to shut down. Default: no
RABBITMQ_CLUSTER_NODE_NAME: Node name to cluster with. E.g.: clusternode@hostname
RABBITMQ_CLUSTER_PARTITION_HANDLING: Cluster partition recovery mechanism. Default: ignore
RABBITMQ_NODE_PORT_NUMBER: Node port. Default: 5672
RABBITMQ_NODE_SSL_PORT_NUMBER: RabbitMQ node port number for SSL connections. Default: 5671
RABBITMQ_SSL_CACERTFILE: Path to the RabbitMQ server SSL CA certificate file. No defaults.
RABBITMQ_SSL_CERTFILE: Path to the RabbitMQ server SSL certificate file. No defaults.
RABBITMQ_SSL_KEYFILE: Path to the RabbitMQ server SSL certificate key file. No defaults.
RABBITMQ_COMBINED_CERT_PATH: Cert- and keyfile are combined automatically into one combined file at this file path. If you are using a combined certificate anyways, mount it to the container and set this path to the mounted file. Default: /tmp/rabbitmq_combined_keys.pem
RABBITMQ_SSL_DEPTH: Maximum number of non-self-issued intermediate certificates that may follow the peer certificate in a valid certification path. No defaults.
RABBITMQ_SSL_FAIL_IF_NO_PEER_CERT: Whether to reject TLS connections if client fails to provide a certificate. Default: verify_none
RABBITMQ_SSL_VERIFY: Whether to enable peer SSL certificate verification. Default: no
RABBITMQ_PLUGINS: Comma, semi-colon or space separated list of plugins to enable during the initialization. No defaults.
RABBITMQ_COMMUNITY_PLUGINS: Comma, semi-colon or space separated list of URLs where to download custom plugins during the initialization. No defaults.
Management server configuration
RABBITMQ_MANAGEMENT_BIND_IP: RabbitMQ management server bind IP address. Default: 0.0.0.0
RABBITMQ_MANAGEMENT_PORT_NUMBER: RabbitMQ management server port number. Default: 15672
RABBITMQ_MANAGEMENT_SSL_PORT_NUMBER: RabbitMQ management server port number for SSL/TLS connections. No defaults.
RABBITMQ_MANAGEMENT_SSL_CACERTFILE: Path to the RabbitMQ management server SSL CA certificate file. No defaults.
RABBITMQ_MANAGEMENT_SSL_CERTFILE: Path to the RabbitMQ management server SSL certificate file. No defaults.
RABBITMQ_MANAGEMENT_SSL_KEYFILE: Path to the RabbitMQ management server SSL certificate key file. No defaults.
RABBITMQ_MANAGEMENT_SSL_DEPTH: Maximum number of non-self-issued intermediate certificates that may follow the peer certificate in a valid certification path, for the RabbitMQ management server. No defaults.
RABBITMQ_MANAGEMENT_SSL_FAIL_IF_NO_PEER_CERT: Whether to reject TLS connections if client fails to provide a certificate for the RabbitMQ management server. Default: yes
RABBITMQ_MANAGEMENT_SSL_VERIFY: Whether to enable peer SSL certificate verification for the RabbitMQ management server. Default: verify_peer
LDAP configuration
RABBITMQ_ENABLE_LDAP: Enable the LDAP configuration. Defaults: no
RABBITMQ_LDAP_TLS: Enable secure LDAP configuration. Defaults: no
RABBITMQ_LDAP_SERVERS: Comma, semi-colon or space separated list of LDAP server hostnames. No defaults.
RABBITMQ_LDAP_SERVERS_PORT: LDAP servers port. Defaults: 389
RABBITMQ_LDAP_USER_DN_PATTERN: DN used to bind to LDAP in the form cn=$${<!-- -->username},dc=example,dc=org. No defaults.
Memory and disk configuration
RABBITMQ_VM_MEMORY_HIGH_WATERMARK: High memory watermark for RabbitMQ to block publishers and prevent new messages from being enqueued. Can be specified as an absolute or relative value (as percentage or value between 0 and 1). No defaults.
RABBITMQ_DISK_FREE_RELATIVE_LIMIT: Disk relative free space limit of the partition on which RabbitMQ is storing data. Default: 1.0
RABBITMQ_DISK_FREE_ABSOLUTE_LIMIT: Disk absolute free space limit of the partition on which RabbitMQ is storing data (takes precedence over the relative limit). No defaults.
RABBITMQ_ULIMIT_NOFILES: Resources limits: maximum number of open file descriptors. Default: 65536

6. Enter the RabbitMQ container to find out

First enter the container

[root@localhost ~]# docker exec -it rabbitmq bin/bash

rabbitmq depends on the erlang environment, so check whether erlang is installed successfully
Enter erl, you can see the following output

```bash
I have no name!@0d5cb60e3a06:/$ erl
Erlang/OTP 24 [erts-12.2] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [jit]

Eshell V12.2 (abort with ^G)
1>

bitnami image, the software is generally installed in the opt/bitnami directory

I have no name!@0d5cb60e3a06:/$ cd opt/bitnami/
I have no name!@0d5cb60e3a06:/opt/bitnami$ ls -al
total 4
drwxrwxr-x. 1 root root 22 Jan 4 2022.
drwxrwxr-x. 1 root root 21 Jan 4 2022 ..
-rw-r--r--. 1 root root 659 Jan 4 2022 .bitnami_components.json
drwxr-xr-x. 4 root root 33 Aug 17 2021 common
drwxr-xr-x. 5 root root 44 Dec 15 2021 erlang
drwxrwxr-x. 2 root root 26 Jan 4 2022 licenses
drwxr-xr-x. 1 root root 45 Jan 4 2022 rabbitmq
drwxrwxr-x. 1 root root 82 Jan 4 2022 scripts

Check whether rabbitmq starts normally
rabbitmqctl status can output a lot of rabbitmq information
Including version information, installed plug-ins, data installation directory, and some indicator information.

I have no name!@0d5cb60e3a06:/opt/bitnami$ rabbitmqctl status
Status of node rabbit@localhost ...
Runtime

OS PID: 213
OS: Linux
Uptime (seconds): 816
Is under maintenance?: false
RabbitMQ version: 3.9.11
Node name: rabbit@localhost
Erlang configuration: Erlang/OTP 24 [erts-12.2] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [jit]
Erlang processes: 378 used, 1048576 limit
Scheduler run queue: 1
Cluster heartbeat timeout (net_ticktime): 60

Plugins

Enabled plugin file: /opt/bitnami/rabbitmq/etc/rabbitmq/enabled_plugins
Enabled plugins:

 *rabbitmq_management
 * amqp_client
 *rabbitmq_web_dispatch
 *cowboy
 *cowlib
 * rabbitmq_management_agent

Data directory

Node data directory: /bitnami/rabbitmq/mnesia/rabbit@localhost
Raft data directory: /bitnami/rabbitmq/mnesia/rabbit@localhost/quorum/rabbit@localhost

Config files

 * /opt/bitnami/rabbitmq/etc/rabbitmq/rabbitmq.conf

Log file(s)

 * /opt/bitnami/rabbitmq/var/log/rabbitmq/rabbit@localhost_upgrade.log
 * <stdout>

Alarms

(none)

Memory

Total memory used: 0.1509 GB
Calculation strategy: rss
Memory high watermark setting: 0.4 of available memory, computed to: 1.1548 GB

reserved_unallocated: 0.0833 GB (55.2%)
code: 0.0347 GB (22.97%)
other_system: 0.0238 GB (15.78%)
other_proc: 0.0192 GB (12.7%)
other_ets: 0.0032 gb (2.09%)
atom: 0.0014 GB (0.94%)
plugins: 0.0014GB (0.9%)
binary: 5.0e-4GB (0.31%)
mgmt_db: 2.0e-4gb (0.15%)
connection_other: 1.0e-4gb (0.09%)
mnesia: 1.0e-4gb (0.07%)
metrics: 1.0e-4gb (0.05%)
msg_index: 1.0e-4gb (0.04%)
connection_readers: 0.0 GB (0.03%)
queue_procs: 0.0GB (0.02%)
quorum_ets: 0.0 GB (0.0 %)
connection_channels: 0.0 GB (0.0 %)
stream_queue_procs: 0.0 GB (0.0 %)
stream_queue_replica_reader_procs: 0.0 GB (0.0 %)
connection_writers: 0.0 GB (0.0 %)
allocated_unused: 0.0 GB (0.0 %)
queue_slave_procs: 0.0 GB (0.0 %)
quorum_queue_procs: 0.0 GB (0.0 %)
stream_queue_coordinator_procs: 0.0 GB (0.0 %)

File Descriptors

Total: 6, limit: 1048479
Sockets: 1, limit: 943629

Free Disk Space

Low free disk space watermark: 2.8869 gb
Free disk space: 10.2966 GB

Totals

Connection count: 1
Queue count: 1
Virtual host count: 2

Listeners

Interface: [::], port: 15672, protocol: http, purpose: HTTP API
Interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication
Interface: [::], port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0

For more rabbitmq operations, you can view it through rabbitmqctl –help

I have no name!@0d5cb60e3a06:/opt/bitnami$ rabbitmqctl --help

7. Extended reading

When playing with containers, when searching for images, you will find that the images in the bitnami warehouse have relatively high stars. Found it really useful!
Attached here
Official website link: https://bitnami.com/stacks
On bitnami’s official website, you can see many packaged applications. The links are github links and related mirror instructions.

The git link of the RabbitMQ image: https://github.com/bitnami/containers/tree/main/bitnami/rabbitmq