DEV Community

ashutosh049
ashutosh049

Posted on • Edited on

Install RabbitMq on Amamzon EC2 (Amazon Linux 2)

Alt Text

Update all the packages to the latest version available.

sudo yum -y update
Enter fullscreen mode Exit fullscreen mode

Package Dependencies before installing RabbitMq

In order to intall rabbitmq, we need to have these packages available:

  1. erlang
  2. socat
  3. logrotate

Enable the EPEL repository

Standard repositories might not provide all the packages that can be installed on CentOS, Red Hat Enterprise Linux (RHEL), or Amazon Linux-based distributions. Enabling the EPEL repository provides additional options for package installation

1.Amazon Linux 2

Install the EPEL release package for EL 7 and enable the EPEL repository.

sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum-config-manager --enable epel
Enter fullscreen mode Exit fullscreen mode

2.Amazon Linux AMI

The EPEL repository is already installed on the original version of Amazon Linux, but you must enable it. You can enable this repository either by using the yum-config-manager command or by editing the epel.repo file.

sudo yum-config-manager --enable epel
Enter fullscreen mode Exit fullscreen mode

See more at ec2-enable-epel


Install Erlang

sudo yum install erlang --enablerepo=epel
Enter fullscreen mode Exit fullscreen mode

TIP: Prevent Erlang unwanted upgrades
To do this, follow:

Install package named yum-plugin-versionlock (called yum-versionlock in RHEL 5).

yum install yum-plugin-versionlock
Enter fullscreen mode Exit fullscreen mode

The /etc/yum/pluginconf.d/versionlock.list will be created on the system.

To install or lock the version of the gcc package, add that package name to the /etc/yum/pluginconf.d/versionlock.list file by running:

yum versionlock gcc-*
Enter fullscreen mode Exit fullscreen mode

Alternatively, you can edit the filelist, /etc/yum/pluginconf.d/versionlock.list, directly.

The above configuration will not allow to upgrade the gcc package to version greater than what was installed at the time the locking was performed.
Yum will attempt to update all packages, while excluding the packages listed in the versionlock file.


Install socat

sudo yum install -y socat
Enter fullscreen mode Exit fullscreen mode

Install logrotate

sudo yum install logrotate
Enter fullscreen mode Exit fullscreen mode

Install RabbitMq

get latest stavble version at http://www.rabbitmq.com/releases/rabbitmq-server, like I chose v3.6.10

wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.10/rabbitmq-server-3.6.10-1.el6.noarch.rpm
sudo rpm -Uvh rabbitmq-server-3.6.10-1.el6.noarch.rpm
Enter fullscreen mode Exit fullscreen mode

Enable RabbitMq management

sudo rabbitmq-plugins enable rabbitmq_management
Enter fullscreen mode Exit fullscreen mode

Set RabbitMQ Server to start automatically on machine-reboot

The RabbitMQ server does not start as a daemon by default when your system starts. If, however, you want it to start by default, then run the following command as the root user or a user with sudo privileges

chkconfig rabbitmq-server on
Enter fullscreen mode Exit fullscreen mode

Start/Stop the server

  • Start: /sbin/service rabbitmq-server start
  • Stop: /sbin/service rabbitmq-server stop
  • Status: /sbin/service rabbitmq-server status

Logging-in to the server management from browser

By default, the guest user is prohibited from connecting from remote hosts; it can only connect over a loopback interface (i.e. localhost). This applies to connections regardless of the protocol. Any other users will not (by default) be restricted in this way.

It is possible to allow the guest user to connect from a remote host by setting the loopback_users configuration to none

# DANGER ZONE!
#
# allowing remote connections for default user is highly discouraged
# as it dramatically decreases the security of the system. Delete the user
# instead and create a new one with generated secure credentials.
loopback_users = none
Enter fullscreen mode Exit fullscreen mode

Or, in the classic config file format (rabbitmq.config):

%% DANGER ZONE!
%%
%% Allowing remote connections for default user is highly discouraged
%% as it dramatically decreases the security of the system. Delete the user
%% instead and create a new one with generated secure credentials.
[{rabbit, [{loopback_users, []}]}].
Enter fullscreen mode Exit fullscreen mode

See more at "guest" user can only connect from localhost

TIP: It is advisable to delete the guest user or at least change its password to reasonably secure generated value that won't be known to the public.


Create new user

  • Add a new/fresh user, say user test and password test:
rabbitmqctl add_user guest1 guest1
Enter fullscreen mode Exit fullscreen mode
  • Give administrative access to the new user:
rabbitmqctl set_user_tags guest1 administrator
Enter fullscreen mode Exit fullscreen mode
  • Set permission to newly created user:
rabbitmqctl set_permissions -p / guest1 ".*" ".*" ".*"
Enter fullscreen mode Exit fullscreen mode

Now try to login via guest1/guest1

Top comments (1)

Collapse
 
siyile profile image
Siyi Le

Thanks, it's helpful!