RabbitMQ deployment options

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:

  • Installing and configuring the broker manually in a virtual machine that is used to distribute it
  • Automatically provisioning in a virtual container hosted directly on the operating system using a tool such as Docker, which provides integration with RabbitMQ
  • Deploying or using managed RabbitMQ instances in the cloud; many platform-as-a-service cloud providers enable the use of such instances in the form of messaging-as-a-service or RabbitMQ-as-a-service (such as the Google Cloud and CloudAMQP platforms)
  • Automatically provisioning a target operating system using a recipe written in a domain-specific language with a provisioning tool such as Puppet or Chef (both of them provide integration with RabbitMQ with some limitations with regard to the target operating systems)
  • Using a combination of the preceding points; automatically creating a VirtualBox (or other) virtual machine or virtual container using Docker, and automatically provisioning the RabbitMQ instances along with their configurations using Puppet or Chef—this can be achieved with a tool such as Vagrant

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.

Puppet

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.

Docker

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:

  • Download and install Docker. If you are using Ubuntu, you can install it using the following command:
    wget -qO- https://get.docker.com/ | sh
  • Download and build the Docker Ubuntu container, and then download and build the RabbitMQ Docker image from the Docker Hub repository using the following commands:
    sudo docker build -t="dockerfile/ubuntu" github.com/dockerfile/ubuntu
    sudo docker build -t="dockerfile/rabbitmq" github.com/dockerfile/rabbitmq
  • Run the RabbitMQ server from the image using the following command:
    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:

  1. Specify the Ubuntu Docker container that will run the RabbitMQ message broker.
  2. Install the RabbitMQ message broker.
  3. Enable the management plugin.
  4. Define /data/mnesia and /data/log as the directories for the RabbitMQ database and log files.
  5. Start the RabbitMQ broker instance.
  6. Expose the RabbitMQ broker instance and management plugin ports (5672 and 15672) from the container.

Vagrant

In case you decide to create a VirtualBox VM with RabbitMQ using a Vagrant script, then perform the following steps:

  1. Download and install Vagrant.
  2. Download and install VirtualBox.
  3. Create a puppet file that provisions the RabbitMQ message broker and enables the management plugin.
  4. Create a Vagrantfile that creates the VirtualBox VM and runs the Puppet script.
  5. Fire up the VM using the following command:
    vagrant up
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.194.106