Rabbitmq is a free and open source message broker system that implements the Advanced Message Queuing Protocol (AMQP). It is also known as message-oriented middleware written in the Erlang programming language and built on the Open Telecom Platform framework for clustering and failover.
Rabbitmq is a scalable implementation of an AMQP broker. AMQP is the most widely used open-source standard for distributing and transferring messages from a source to a destination.
The Rabbitmq message broker system provides lot's of features some of them are listed below:
- Supports multiple protocols such as MQTT, STOMP and HTTP.
- Supports routing capabilities, you can implement rules to route messages between exchanges and queues.
- Supports multiple programming language with a variety of supported clients.
- Supports clustering, so you can clustered several rabbinmq server on local network.
- Supports high availability, so if a broker fails then communication will be redirected to different broker instance.
- Provides user friendly web interface to monitor and control every aspect of your message broker.
- Rabbitmq comes with lot's of plugins, you can easily extend it and also write your own.
- Rabbitmq provides tracing features that can be used to find out what's going on.
In this tutorial, we will learn how to install rabbitmq on Ubuntu 16.04 server.
- A server running Ubuntu 16.04.
- A non-root user with sudo privileges configure on your server.
Before starting, you will need to update Ubuntu repository with the latest one.
You can do this by running the following commands:
sudo apt-get update -y
sudo apt-get upgrade -y
Before installing rabbitmq, you will need to install erlang as a prerequisite of rabbitmq. You can install them by running the following commands:
sudo apt-key add erlang_solutions.asc
sudo apt-get update -y
sudo apt-get install erlang -y
sudo apt-get install erlang-nox -y
Once you have Erlang, you can continue with installing RabbitMQ:
First, you will need to add rabbitmq repository to apt. You can easily add it with the following command:
sudo echo "deb http://www.rabbitmq.com/debian/ testing main" >> /etc/apt/sources.list
Once the repository is added, you will need to add the RabbitMQ public key to our trusted key list to avoid any warnings about unsigned packages:
sudo apt-key add rabbitmq-signing-key-public.asc
Next update the apt repository with the following command:
sudo apt-get update
Once the repository is up to date, then install rabbitmq server by running the following command:
sudo apt-get install rabbitmq-server
Once installation is complete, start the rabbitmq server and enable it to start on boot by running the following command:
sudo systemctl start rabbitmq-server
sudo systemctl enable rabbitmq-server
You can check the status of rabbitmq server with the following command:
sudo systemctl status rabbitmq-server
RabbitMQ comes with default built-in settings which will quite likely be sufficient for running your RabbitMQ server effectively. If it runs fine, then you possibly don't need any configuration at all.
There are three way to customize RabbitMQ server.
- environment variables
You can define ports, file location and names using environment variable file.
- configuration file
You can defines server component settings for permissions, limits and clusters using configuration file.
- runtime parameters and policies You can defines cluster-wide settings which can change at run time .
You can find location of configuration file by inspecting RabbitMQ log file.
If you want to manage the maximum amount of connections upon launch, then you will need to modify
rabbitmq-server file located at /etc/default/ directory.
sudo nano /etc/default/rabbitmq-server
Find the line that containing word
ulimit and uncomment it:
ulimit -n 1024
Save and close the file, then you can proceed to next step.
Allow RabbitMQ Through Firewall
By default RabbitMQ web management console runs on port
15672. So you will need to allow this port through UFW firewall. By default UFW firewall is disabled in Ubuntu 16.04, so you will need to enable it first.
You can enable UFW filrewall with the following command:
sudo ufw enable
Once UFW is enabled, allow port
15672 using the following command:
sudo ufw allow 15672
Once you are done, you can proceed to next step.
Accessing RabbitMQ Web Management Console
Once everything is setup properly, it's time to access Rabbitmq web management console. Before starting, you will need to install rabbitmq web management plugin first. You can easily manage and monitor your RabbitMQ server in a variety of ways using this plugin. Using this console, you can manage queues, bindings and users, monitor queues, message rates, connections and also monitor Erlang processes, memory usage etc.
To install this plugin simply run the following command:
sudo rabbitmq-plugins enable rabbitmq_management
The above command will enable the following plugins:
Once the plugin is enabled, you will need to restart rebbitmq service for the changes to come into effect.
Next, you will also need to create new admin user.
You can create a new admin user with the following commands:
sudo rabbitmqctl add_user radmin radmin
sudo rabbitmqctl set_user_tags radmin administrator
sudo rabbitmqctl set_permissions -p / radmin ".*" ".*" ".*"
Next, open your favourite web browser and type the URL
http://server-ip-address:15672 and login with your newly create user and password.
After login the RabbitMQ web management console you should see the dashboard in following image:
Finally, you have successfully installed RabbitMQ server on Ubuntu 16.04. You can now easily manage your RabbitMQ server from your web.
In this tutorial, you have learn how to install RabbitMQ server on Ubuntu 16.04 server. You have also learned how to enable the RabbitMQ web management plugins. I hope, you can now easily deploy RabbitMQ server in production environment.