0 votes
383 views
in RabbitMQ by (3.9k points)
How To Install RabbitMQ on Ubuntu ?

1 Answer

0 votes
by (3.9k points)

RabbitMQ:- RabbitMQ is an open source message broker that implements the AMQP (Advanced Message Queuing Protocol) protocol. RabbitMQ is Streaming Text Oriented Messaging Protocol, Message Queuing Telemetry Transport and other protocols via Plugins.

The main work of a Messaging broker is to receive messages from publishers and route them to consumers.

There are Following steps to install RabbitMQ Server on Ubuntu:-

Step 1: First of all Install Erlang/OTP
RabbitMQ requires Erlang to be installed first before RabbitMQ can run.

Once the Erlang has been installed then proceed to next step.
Step 2: Add RabbitMQ Repository To Ubuntu
Import RabbitMQ:-
wget -O- https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc | sudo apt-key add -
wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add -

Now added the RabbitMQ Repository on Ubuntu by using given command:-
echo "deb https://dl.bintray.com/rabbitmq/debian $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/rabbitmq.list

Step 3: To Install RabbitMQ Server on Ubuntu, update apt list, then install rabbitmq-server package
sudo apt update
sudo apt -y install rabbitmq-server

After installation, RabbitMQ service is started and enabled to start on boot. To check the status, run:

$ sudo systemctl status  rabbitmq-server.service
* rabbitmq-server.service - RabbitMQ broker
   Loaded: loaded (/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2018-10-24 13:14:42 PDT; 1min 11s ago
 Main PID: 9525 (beam.smp)
   Status: "Initialized"
    Tasks: 87 (limit: 1111)
   CGroup: /system.slice/rabbitmq-server.service
           |-9525 /usr/lib/erlang/erts-10.1/bin/beam.smp -W w -A 64 -MBas ageffcbf -MHas ageffcbf -MBlmbcs 512 -MHlmbcs 512 -MMmcs 30 -P 1048576 -t 50
           |-9622 /usr/lib/erlang/erts-10.1/bin/epmd -daemon
           |-9778 erl_child_setup 32768
           |-9797 inet_gethost 4
           `-9798 inet_gethost 4

Oct 24 13:14:18 ubuntu-01 rabbitmq-server[9525]:   ##  ##
Oct 24 13:14:18 ubuntu-01 rabbitmq-server[9525]:   ##  ##      RabbitMQ 3.7.8. Copyright (C) 2007-2018 Pivotal Software, Inc.
Oct 24 13:14:18 ubuntu-01 rabbitmq-server[9525]:   ##########  Licensed under the MPL.  See http://www.rabbitmq.com/
Oct 24 13:14:18 ubuntu-01 rabbitmq-server[9525]:   ######  ##
Oct 24 13:14:18 ubuntu-01 rabbitmq-server[9525]:   ##########  Logs: /var/log/rabbitmq/[email protected]
Oct 24 13:14:18 ubuntu-01 rabbitmq-server[9525]:                     /var/log/rabbitmq/[email protected]_upgrade.log
Oct 24 13:14:18 ubuntu-01 rabbitmq-server[9525]:               Starting broker...
Sept 04 13:14:42 ubuntu-01 rabbitmq-server[9525]: systemd unit for activation check: "rabbitmq-server.service"
Sept 04 13:14:42 ubuntu-01 systemd[1]: Started RabbitMQ broker.
Sept 04 13:14:42 ubuntu-01 rabbitmq-server[9525]:  completed with 0 plugins.

Confirm the service is configured to start on boot using the command:
$ systemctl is-enabled rabbitmq-server.service
enabled

If it returns disabled, enable it by running:
sudo systemctl enable rabbitmq-server

Step 4: Enable the RabbitMQ Management Dashboard (Optional)
You can optionally enable the RabbitMQ Management Web dashboard for easy management.

sudo rabbitmq-plugins enable rabbitmq_management
The Web service should be listening on TCP port 15672

# ss -tunelp | grep 15672
tcp   LISTEN  0       128                    0.0.0.0:15672        0.0.0.0:*      users:(("beam.smp",pid=9525,fd=71)) uid:111 ino:39934 sk:9 <->

If you have an active UFW firewall, open both ports 5672 and 15672

sudo ufw allow proto tcp from any to any port 5672,15672

To Access it by using the URL http://[server IP|Hostname]:15672
RabbitMQ Dahsboard
By default, the guest user exists and can connect only from localhost. You can login with guest user locally with the password “guest”

To be able to login on the network, create an admin user like below:

rabbitmqctl add_user admin StrongPassword
rabbitmqctl set_user_tags admin administrator

Login with this admin username and the password assigned.
RabbitMQ Admin Dahsboard
Step 5: Set RabbitMQ Cluster (Optional)

If you need to achieve high availability and higher throughput, consider configuring RabbitMQ cluster on your Ubuntu servers see the following the command:

To Configure RabbitMQ Cluster on Ubuntu:-

RabbitMQ User Management Commands

Delete User:-
rabbitmqctl delete_user user

Change User Password:-
rabbitmqctl change_password user strongpassword

Create new Virtualhost:-
rabbitmqctl add_vhost /my_vhost

List available Virtualhosts:-
rabbitmqctl list_vhosts

Delete a virtualhost:-
rabbitmqctl delete_vhost /myvhost

Grant user permissions for vhost:-
rabbitmqctl set_permissions -p /myvhost user ".*" ".*" ".*"

List vhost permissions:-
rabbitmqctl list_permissions -p /myvhost

To list user permissions:-
rabbitmqctl list_user_permissions user

Delete user permissions:-
rabbitmqctl clear_permissions -p /myvhost user

Share:- Whatsapp Facebook Facebook


Welcome to Developerhelpway Q&A, where you can ask questions and receive answers from other members of the community.

Categories

...