So far, we have been manually configuring our RabbitMQ instances. However, it's common for many production systems to use automatic provisioning and management of the configuration of components, including the message broker. There are a number of ways in which we can deploy and manage a RabbitMQ broker instance:
In this section, we will look at some of the most widely used tools that allow us to deploy and configure the message broker using any of the preceding mechanisms.
Download the open source version of the Puppet tool for your operating system (we will be using the one for Windows) from the Puppetlabs site and install it:
puppet module install puppetlabs-rabbitmq
After you install Puppet, you can install the RabbitMQ module using the following command. Note that the RabbitMQ Puppet plugin does not support a Windows-based configuration at the time of writing this book; you can try it with a Debian-based distribution such as RedHat or supply your own Puppet class that does the provisioning on Windows.
Create a file named rabbitmq.pp
with the following contents that specifies the configuration of your RabbitMQ instance:
class { 'rabbitmq': port => '5666', service_manage => true, environment_variables => { 'RABBITMQ_NODENAME' => 'RabbitMQ_Puppet', 'RABBITMQ_SERVICENAME' => 'RabbitMQ_Puppet' } }
To provision the instance on the same local machine, use the following command:
puppet apply rabbitmq.pp
Note that in a production scenario, you will typically use a master/client Puppet setup rather than local provisioning.
A Docker file contains the instructions to build a docker image. A RabbitMQ broker instance is started in a separate process running from a Docker image. The image runs the RabbitMQ instance in a Docker container. As Docker contains Linux-specific commands, you must run the image in a Linux environment (for example, Ubuntu). The steps required in order to run the image are as follows:
wget -qO- https://get.docker.com/ | sh
sudo docker build -t="dockerfile/ubuntu" github.com/dockerfile/ubuntu sudo docker build -t="dockerfile/rabbitmq" github.com/dockerfile/rabbitmq
sudo docker run -d -p 5672:5672 -p 15672:15672 dockerfile/rabbitmq
The –p
argument specifies port redirection. In the preceding case, RabbitMQ ports 5672
and 15672
from the docker image are mapped to ports 5672
and 15672
from the host machine. The steps defined in the RabbitMQ image are as follows:
/data/mnesia
and /data/log
as the directories for the RabbitMQ database and log files.5672
and 15672
) from the container.In case you decide to create a VirtualBox VM with RabbitMQ using a Vagrant script, then perform the following steps:
vagrant up
3.141.192.120