Linux Administrator

How to Install RabbitMQ on CentOS 7

rabbitmq-installation
mm
Written by Santosh Prasad

RabbitMQ is an open source most popular message broker software that implements the Advanced Message Queuing Protocol (AMQP). It is written in the Erlang programming language. RabbitMQ can be easily deployed in a distributed and federated configurations to meet high-scale, high-availability requirements.

In this article I will show you how to install RabbitMQ on CentOS 7.

Prerequisites

1. Needed CentOS 7 Operating system.
2. Need root access or sudo privileges.

Install RabbitMQ on CentOS 7

First of all you have to add the Erlang yum repository on your CentOS system. You can download the Erlang repository package from its official website and install it on your server like below.

Install Erlang

# wget http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
--2017-12-03 23:31:05--  http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
Resolving packages.erlang-solutions.com... 31.172.186.53
Connecting to packages.erlang-solutions.com|31.172.186.53|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1932 (1.9K) [application/x-redhat-package-manager]
Saving to: “erlang-solutions-1.0-1.noarch.rpm”

100%[================================================================================================================>] 1,932       --.-K/s   in 0s

2017-12-03 23:31:05 (143 MB/s) - “erlang-solutions-1.0-1.noarch.rpm” saved [1932/1932]
# ls
erlang-solutions-1.0-1.noarch.rpm
# rpm -Uvh erlang-solutions-1.0-1.noarch.rpm
Preparing...                ########################################### [100%]
   1:erlang-solutions       ########################################### [100%]
--2017-12-03 23:31:20--  http://packages.erlang-solutions.com/rpm/centos/erlang_solutions.repo
Resolving packages.erlang-solutions.com... 31.172.186.53
Connecting to packages.erlang-solutions.com|31.172.186.53|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 245
Saving to: “erlang_solutions.repo”

100%[================================================================================================================>] 245         --.-K/s   in 0s

2017-12-03 23:31:20 (20.9 MB/s) - “erlang_solutions.repo” saved [245/245]

Once download completed, now install Erlang package on your system using below command.

# yum install erlang
Loaded plugins: fastestmirror, presto
Setting up Install Process
Determining fastest mirrors
epel/metalink                                                                                                                      |  15 kB     00:00
 * base: mirrors.advancedhosters.com
 * epel: mirror.us.leaseweb.net
 * extras: mirror.solarvps.com
 * updates: repos-va.psychz.net
base                                                                                                                               | 3.7 kB     00:00
epel                                                                                                                               | 4.7 kB     00:00
epel/primary_db                                                                                                                    | 6.0 MB     00:00
erlang-solutions                                                                                                                   |  951 B     00:00
erlang-solutions/primary                                                                                                           | 1.1 MB     00:01
erlang-solutions                                                                                                                                1316/1316
extras                                                                                                                             | 3.4 kB     00:00
updates                                                                                                                            | 3.4 kB     00:00
updates/primary_db                                                                                                                 | 5.3 MB     00:00
Resolving Dependencies
--> Running transaction check
---> Package erlang.x86_64 0:20.1-1.el6 will be installed
--> Processing Dependency: erlang-tools(x86-64) = 20.1-1.el6 for package: erlang-20.1-1.el6.x86_64
--> Processing Dependency: erlang-odbc(x86-64) = 20.1-1.el6 for package: erlang-20.1-1.el6.x86_64
--> Processing Dependency: erlang-observer(x86-64) = 20.1-1.el6 for package: erlang-20.1-1.el6.x86_64
--> Processing Dependency: erlang-ssh(x86-64) = 20.1-1.el6 for package: erlang-20.1-1.el6.x86_64
--> Processing Dependency: erlang-cosEvent(x86-64) = 20.1-1.el6 for package: erlang-20.1-1.el6.x86_64
--> Processing Dependency: erlang-xmerl(x86-64) = 20.1-1.el6 for package: erlang-20.1-1.el6.x86_64
--> Processing Dependency: erlang-otp_mibs(x86-64) = 20.1-1.el6 for package: erlang-20.1-1.el6.x86_64
--> Processing Dependency: erlang-runtime_tools(x86-64) = 20.1-1.el6 for package: erlang-20.1-1.el6.x86_64
--> Processing Dependency: erlang-cosFileTransfer(x86-64) = 20.1-1.el6 for package: erlang-20.1-1.el6.x86_64
--> Processing Dependency: erlang-hipe(x86-64) = 20.1-1.el6 for package: erlang-20.1-1.el6.x86_64
--> Processing Dependency: erlang-stdlib(x86-64) = 20.1-1.el6 for package: erlang-20.1-1.el6.x86_64
--> Processing Dependency: erlang-debugger(x86-64) = 20.1-1.el6 for package: erlang-20.1-1.el6.x86_64
.............
.........
Dependency Installed:
  SDL.x86_64 0:1.2.14-7.el6_7.1                      erlang-asn1.x86_64 0:20.1-1.el6                    erlang-common_test.x86_64 0:20.1-1.el6
  erlang-compiler.x86_64 0:20.1-1.el6                erlang-cosEvent.x86_64 0:20.1-1.el6                erlang-cosEventDomain.x86_64 0:20.1-1.el6
  erlang-cosFileTransfer.x86_64 0:20.1-1.el6         erlang-cosNotification.x86_64 0:20.1-1.el6         erlang-cosProperty.x86_64 0:20.1-1.el6
  erlang-cosTime.x86_64 0:20.1-1.el6                 erlang-cosTransactions.x86_64 0:20.1-1.el6         erlang-crypto.x86_64 0:20.1-1.el6
  erlang-debugger.x86_64 0:20.1-1.el6                erlang-dialyzer.x86_64 0:20.1-1.el6                erlang-diameter.x86_64 0:20.1-1.el6
  erlang-edoc.x86_64 0:20.1-1.el6                    erlang-eldap.x86_64 0:20.1-1.el6                   erlang-erl_docgen.x86_64 0:20.1-1.el6
  erlang-erl_interface.x86_64 0:20.1-1.el6           erlang-erts.x86_64 0:20.1-1.el6                    erlang-et.x86_64 0:20.1-1.el6
  erlang-eunit.x86_64 0:20.1-1.el6                   erlang-examples.x86_64 0:20.1-1.el6                erlang-hipe.x86_64 0:20.1-1.el6
  erlang-ic.x86_64 0:20.1-1.el6                      erlang-inets.x86_64 0:20.1-1.el6                   erlang-jinterface.x86_64 0:20.1-1.el6
  erlang-kernel.x86_64 0:20.1-1.el6                  erlang-megaco.x86_64 0:20.1-1.el6                  erlang-mnesia.x86_64 0:20.1-1.el6
  erlang-observer.x86_64 0:20.1-1.el6                erlang-odbc.x86_64 0:20.1-1.el6                    erlang-orber.x86_64 0:20.1-1.el6
  erlang-os_mon.x86_64 0:20.1-1.el6                  erlang-otp_mibs.x86_64 0:20.1-1.el6                erlang-parsetools.x86_64 0:20.1-1.el6
  erlang-public_key.x86_64 0:20.1-1.el6              erlang-reltool.x86_64 0:20.1-1.el6                 erlang-runtime_tools.x86_64 0:20.1-1.el6
  erlang-sasl.x86_64 0:20.1-1.el6                    erlang-snmp.x86_64 0:20.1-1.el6                    erlang-ssh.x86_64 0:20.1-1.el6
  erlang-ssl.x86_64 0:20.1-1.el6                     erlang-stdlib.x86_64 0:20.1-1.el6                  erlang-syntax_tools.x86_64 0:20.1-1.el6
  erlang-tools.x86_64 0:20.1-1.el6                   erlang-typer.x86_64 0:20.1-1.el6                   erlang-wx.x86_64 0:20.1-1.el6
  erlang-xmerl.x86_64 0:20.1-1.el6                   libXxf86vm.x86_64 0:1.1.3-2.1.el6                  libtool-ltdl.x86_64 0:2.2.6-15.5.el6
  mesa-dri-drivers.x86_64 0:11.0.7-4.el6             mesa-dri-filesystem.x86_64 0:11.0.7-4.el6          mesa-dri1-drivers.x86_64 0:7.11-8.el6
  mesa-libGL.x86_64 0:11.0.7-4.el6                   mesa-libGLU.x86_64 0:11.0.7-4.el6                  mesa-private-llvm.x86_64 0:3.6.2-1.el6
  unixODBC.x86_64 0:2.2.14-14.el6                    wxBase.x86_64 0:2.8.12-1.el6.centos                wxGTK.x86_64 0:2.8.12-1.el6.centos
  wxGTK-gl.x86_64 0:2.8.12-1.el6.centos

Complete!

Now verify Erlang installation using below command.

# erl
Erlang/OTP 20 [erts-9.1] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V9.1  (abort with ^G)

Press Ctrl+c twice to exit the Erlang screen.

Install RabbitMQ Server

Next, after installing requirements now download and install RabbitMQ server.

# wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.1/rabbitmq-server-3.6.1-1.noarch.rpm
--2017-12-03 23:34:54--  https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.1/rabbitmq-server-3.6.1-1.noarch.rpm
Resolving www.rabbitmq.com... 104.20.63.197, 104.20.62.197, 2400:cb00:2048:1::6814:3ec5, ...
Connecting to www.rabbitmq.com|104.20.63.197|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5088884 (4.9M) [application/x-redhat-package-manager]
Saving to: “rabbitmq-server-3.6.1-1.noarch.rpm”

100%[================================================================================================================>] 5,088,884   --.-K/s   in 0.08s

2017-12-03 23:34:54 (63.4 MB/s) - “rabbitmq-server-3.6.1-1.noarch.rpm” saved [5088884/5088884]
# rpm --import https://www.rabbitmq.com/rabbitmq-signing-key-public.asc
# yum install rabbitmq-server-3.6.1-1.noarch.rpm
Loaded plugins: fastestmirror, presto
Setting up Install Process
Examining rabbitmq-server-3.6.1-1.noarch.rpm: rabbitmq-server-3.6.1-1.noarch
Marking rabbitmq-server-3.6.1-1.noarch.rpm to be installed
Loading mirror speeds from cached hostfile
 * base: mirrors.advancedhosters.com
 * epel: mirror.us.leaseweb.net
 * extras: mirror.solarvps.com
 * updates: repos-va.psychz.net
Resolving Dependencies
--> Running transaction check
---> Package rabbitmq-server.noarch 0:3.6.1-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================================================
 Package                              Arch                        Version                      Repository                                            Size
==========================================================================================================================================================
Installing:
 rabbitmq-server                      noarch                      3.6.1-1                      /rabbitmq-server-3.6.1-1.noarch                      5.5 M

Transaction Summary
==========================================================================================================================================================
Install       1 Package(s)

Total size: 5.5 M
Installed size: 5.5 M

Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : rabbitmq-server-3.6.1-1.noarch                                                                                                         1/1
  Verifying  : rabbitmq-server-3.6.1-1.noarch                                                                                                         1/1

Installed:
  rabbitmq-server.noarch 0:3.6.1-1

Complete!

Edit Firewall Rules

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

# 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

# firewall-cmd --reload

Now start the RabbitMQ server and enable it to start on the system boot.

# /etc/init.d/rabbitmq-server start
Starting rabbitmq-server: FAILED - check /var/log/rabbitmq/startup_{log, _err}
rabbitmq-server.

If you are getting above error, you will need to edit your /etc/hosts file as below to fix this.

# vim /etc/hosts
127.0.0.1 hostname

Save and close.

Then now start the rabbitmq service again and you will get success message like below.

# /etc/init.d/rabbitmq-server start
Starting rabbitmq-server: SUCCESS
rabbitmq-server.

Now you can check the RabbitMQ status using below command.

# rabbitmqctl status
Status of node [email protected] ...
[{pid,28068},
 {running_applications,[{rabbit,"RabbitMQ","3.6.1"},
                        {mnesia,"MNESIA  CXC 138 12","4.15.1"},
                        {os_mon,"CPO  CXC 138 46","2.4.3"},
                        {rabbit_common,[],"3.6.1"},
                        {xmerl,"XML parser","1.3.15"},
                        {ranch,"Socket acceptor pool for TCP protocols.",
                               "1.2.1"},
                        {sasl,"SASL  CXC 138 11","3.1"},
                        {stdlib,"ERTS  CXC 138 10","3.4.2"},
                        {kernel,"ERTS  CXC 138 10","5.4"}]},
 {os,{unix,linux}},
 {erlang_version,"Erlang/OTP 20 [erts-9.1] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:64] [hipe] [kernel-poll:true]\n"},
 {memory,[{total,42048456},
          {connection_readers,0},
          {connection_writers,0},
          {connection_channels,0},
          {connection_other,0},
          {queue_procs,2840},
          {queue_slave_procs,0},
          {plugins,0},
          {other_proc,17661608},
          {mnesia,61816},
          {mgmt_db,0},
          {msg_index,35064},
          {other_ets,912184},
          {binary,20576},
          {code,15747902},
          {atom,703401},
          {other_system,6903065}]},
 {alarms,[]},
 {listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},
 {vm_memory_high_watermark,0.4},
 {vm_memory_limit,1522479923},
 {disk_free_limit,50000000},
 {disk_free,699723776},
 {file_descriptors,[{total_limit,924},
                    {total_used,2},
                    {sockets_limit,829},
                    {sockets_used,0}]},
 {processes,[{limit,1048576},{used,139}]},
 {run_queue,0},
 {uptime,356},
 {kernel,{net_ticktime,60}}]

Create Admin User and Password For RabbitMQ

By default rabbitmb create user and password named “guest” with password “guest”. Now create your own admin user and password for accessing the RabbitMQ server management console using bellow command.

# sudo rabbitmqctl add_user admin password 
# sudo rabbitmqctl set_user_tags admin administrator
# sudo rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"

Setup RabbitMQ Web Management Console

You can also manage RabbitMQ using web management console. Follow the below command to enable the web management console.

# rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:
  mochiweb
  webmachine
  rabbitmq_web_dispatch
  amqp_client
  rabbitmq_management_agent
  rabbitmq_management

Applying plugin configuration to [email protected]… started 6 plugins.

# chown -R rabbitmq:rabbitmq /var/lib/rabbitmq/

Now open your web browser and type the below URL in browser.

http://your_server_ip_and_domain_name:15672

rabbitmq-login

Use the username and password created before.

RabbitMQ Dashboard

rabbitmq-dashboard

Thank you! for visiting Look Linux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at Look Linux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment