Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / DevOps / deployment

RabbitMQ – Customize Manual Installation for Windows

4.00/5 (3 votes)
30 Dec 2016CPOL4 min read 15.1K  
This article provides the step-by-step points on customising manual installation of RabbitMQ on Windows.

Introduction

Installing RabbitMQ using standard installer (available here) is quite easy and the recommended way of setting up the server. But there could be scenarios or situations when you would like to customize the installation. For instance, you may have a requirement to package RabbitMQ along with the product you want to ship, or you wish to write batch scripts. Well, this article touches on the important areas which will help you customize the installation and packaging.

RabbitMQ documentation explains every aspect of this in detail. This article compiles and summarizes the steps with an objective to make you understand the process and dependencies.

Download Details

You first need to download the following:

  • Download Erlang OTP 19.0 (click here).
  • Download RabbitMQ 3.6.5 manual zip package (click here) (rabbitmq-server-windows-3.6.5.zip)

Note: Erlang OTP & RabbitMQ versions mentioned above were latest when I wrote this article.

Installation Steps

Step 1

Install Erlang OTP by following the directions in the installation wizard. It will also prompt you to install Microsoft VC++ 2013 redistributable if your system does not have it already.

Step 2

Extract rabbitmq-server-windows-3.6.5.zip and copy it to C:\MyMessageBroker\Install. Please note that you can choose any location on your system. For the sake of understanding, let’s assume this location. The steps below also reference the same location.

Step 3

Set ERLANG_HOME environment variable to where you actually put your Erlang installation, e.g. C:\Program Files\erlx.x.x (full path).

(The RabbitMQ batch files are expected to execute %ERLANG_HOME%\bin\erl.exe.)

Step 4

Set RabbitMQ environment variable:

Note: In case you are setting up cluster on a single machine, you will have to ensure all nodes have unique ports. In the next section, we will setup cluster of two nodes.

Set the following environment variables:

  • RABBITMQ_NODE_PORT - The port number on which RabbitMQ service will listen. The default value for this is 5762
  • RABBITMQ_DIST_PORT - This is used for inter-node and CLI tool communication. The value is set by adding 20000 to the value of RABBITMQ_NODE_PORT variable. However, if you wish to use configuration files, then the values provided there will be used. For more information, see “Networking” section of RabbitMQ documentation. Let’s set the value as (RABBITMQ_NODE_PORT + 20000) 25672
  • RABBITMQ_SERVICENAME - When you use the default installer, RabbitMQ installs Windows service with name “RabbitMQ”. However, we can change this by setting value to RABBITMQ_SERVICENAME variable. Set value for RABBITMQ_SERVICENAME as “MyMessageBroker”.
  • RABBITMQ_BASE - Set the RABBITMQ_BASE variable value of the path where we extracted the zip package C:\MyMessageBroker\Install
  • RABBITMQ_NODENAME - Node name should always be unique. The qualified node name format is “MyNode1@MachineName”. The value for this variable can be “MyNode1” , for instance, and it will internally derive the qualified name. Let's set the value "MyNode1" for this variable.
  • RABBITMQ_CONFIG_FILE - Set RABBITMQ_CONFIG_FILE variable as %RABBITMQ_BASE%\rabbitmq. This path indicates the base directory location and primary name of the configuration file. That is, the primary name here is “rabbitmq” which will be referenced as “rabbitmq.config” at base location.
  • Similarly, set the values for all the variables listed in the list below with the corresponding values:
  • RABBITMQ_MNESIA_BASE = %RABBITMQ_BASE%\db
  • RABBITMQ_MNESIA_DIR = %RABBITMQ_MNESIA_BASE%\%RABBITMQ_NODENAME%
  • RABBITMQ_LOG_BASE = %RABBITMQ_BASE%\log
  • RABBITMQ_LOGS = %RABBITMQ_LOG_BASE%\%RABBITMQ_NODENAME%.log
  • RABBITMQ_SASL_LOGS = %RABBITMQ_LOG_BASE%\%RABBITMQ_NODENAME%-sasl.log
  • RABBITMQ_PLUGINS_DIR = %RABBITMQ_BASE%\plugins
  • RABBITMQ_ENABLED_PLUGINS_FILE = %RABBITMQ_BASE%\enabled_plugins

Step 5

After completing the entire configuration above, install RabbitMQ as windows service. Open the command window (as administrator) and navigate to the “sbin” directory located at the base location, i.e., C:\MyMessageBroker\Install\sbin.

Execute the following command to install the service:

C++
$> rabbitmq-service install

After successfully completing Step 5, our messaging server is up and running. You can open the services console and locate “MyMessageBroker” service in the list.

Creating a Cluster

We can follow the above 5 steps on another machine with different Node Name (say MyNode2) and then join this node to form a cluster. We have to ensure that on the second machine, we have the same erlang cookie value.

In case of clustering, the nodes (and CLI tools) authenticate each other using the Erlang cookie. It is a plain text file with the some value. The name of this file is “.erlang.cookie

On Windows, the locations are:

  1. C:\Users\Current User\.erlang.cookie (%HOMEDRIVE% + %HOMEPATH%\.erlang.cookie), or C:\Documents and Settings\Current User\.erlang.cookie, and
  2. C:\Windows\.erlang.cookie for RabbitMQ Windows service

Since RabbitMQ is installed as Windows service, the cookie should be placed at both the locations.

On the second machine, locate and edit the ".erlang.cookie" file and set the value that matches the value on the first machine.

After completing the 5 steps above and setting the cookie value, open command window and navigate to “sbin” location. Then, execute the following commands to join with first node:

C++
$> rabbitmqctl stop_app 

Executing the above command will stop the node. Now you can use join_cluster command to form cluster:

C++
$> rabbitmqctl join_cluster MyNode1@MachineName 

The successful execution of the above command will display message that will look like this:

C++
$> ....Clustering node MyNode2@MachineName with [MyNode1@MachineName] ...done 

You can then check the status of cluster by issuing the following command:

C++
$> rabbitmqctl cluster_status 

We have completed the RabbitMQ manual installation with clustering enabled. After you install and run Management plug in, you will see two nodes in the "Overview" section.

Hope this article has helped you get started with the RabbitMQ manual installation.

Happy learning!! :-)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)