Install RabbitMQ on RHEL/CentOS

NOTE: Sensu Support is available for RabbitMQ versions 3.6.4 and newer (on Erlang version 19.3 or newer).

Install Erlang (the RabbitMQ runtime)

RabbitMQ runs on the Erlang runtime, so before you can install and run RabbitMQ, you’ll need to install Erlang.

Although Erlang runtime packages are included in the RPM repositories for most distributions, the included versions often lag behind what is supported by RabbitMQ releases. Per the RabbitMQ Erlang version requirements documentation:

Erlang/OTP versions older than 19.3 are not supported by currently maintained RabbitMQ release series.

As a result, you will probably get better results installing a newer version of Erlang from an alternative source. Please see the Erlang version requirements documentation for information on selecting and installing a compatible version of the Erlang runtime.

Install RabbitMQ

Although RabbitMQ packages are included in the RPM-based distribution repositories, the included versions often lag behind the supported RabbitMQ release series.

Please see the official RabbitMQ installation guide for recommended installation strategies.

Managing the RabbitMQ service/process

  1. Install the RabbitMQ init scripts using the chkconfig utility:

    sudo chkconfig rabbitmq-server on

  2. Start and stop the RabbitMQ service using the installed init scripts: NOTE: The service command will not work on CentOS 5, the sysvinit script must be used, e.g. sudo /etc/init.d/rabbitmq-server start

    sudo service rabbitmq-server start
    sudo service rabbitmq-server stop

Configure RabbitMQ access controls

Access to RabbitMQ is restricted by access controls (e.g. username and password). For Sensu services to connect to RabbitMQ a RabbitMQ virtual host (vhost) and user credentials will need to be created.

Create a dedicated RabbitMQ vhost for Sensu

sudo rabbitmqctl add_vhost /sensu

Create a RabbitMQ user for Sensu

sudo rabbitmqctl add_user sensu secret
sudo rabbitmqctl set_permissions -p /sensu sensu ".*" ".*" ".*"

Configure system limits on Linux

By default, most Linux operating systems will limit the maximum number of file handles a single process is allowed to have open to 1024. RabbitMQ recommends adjusting this number to 65536 for production systems, and at least 4096 for development environments.

RabbitMQ installations running production workloads may need system limits and kernel parameters tuning in order to handle a decent number of concurrent connections and queues. The main setting that needs adjustment is the max number of open files, also known as ulimit -n. The default value on many operating systems is too low for a messaging broker (eg. 1024 on several Linux distributions). We recommend allowing for at least 65536 file descriptors for user rabbitmq in production environments. 4096 should be sufficient for most development workloads.

There are two limits in play: the maximum number of open files the OS kernel allows (fs.file-max) and the per-user limit (ulimit -n). The former must be higher than the latter.

Source: rabbitmq.com

To adjust this limit, please edit the configuration file found at /etc/defaults/rabbitmq-server by uncommenting the last line in the file, and adjusting the ulimit value to the recommendation corresponding to the environment where RabbitMQ is running.

# This file is sourced by the rabbitmq-server service script. Its primary
# reason for existing is to allow adjustment of system limits for the
# rabbitmq-server process.
#
# Maximum number of open file handles. This will need to be increased
# to handle many simultaneous connections. Refer to the system
# documentation for ulimit (in man bash) for more information.
#
ulimit -n 65536

Verifying the Limit

To verify that the RabbitMQ open file handle limit has been increase, please run:

rabbitmqctl status

Configure Sensu

The following Sensu configuration files are provided as examples. Please review the RabbitMQ reference documentation for additional information on configuring Sensu to communicate with RabbitMQ, and the reference documentation on Sensu configuration for more information on how Sensu loads configuration.

Example Standalone Configuration

  1. Copy the following contents to a configuration file located at /etc/sensu/conf.d/rabbitmq.json:
    {
      "rabbitmq": {
        "host": "127.0.0.1",
        "port": 5672,
        "vhost": "/sensu",
        "user": "sensu",
        "password": "secret"
      }
    }

Example Distributed Configuration

  1. Obtain the IP address of the system where RabbitMQ is installed. For the purpose of this example, we will assume 10.0.1.6 is our IP address.

  2. Create a configuration file with the following contents at /etc/sensu/conf.d/rabbitmq.json on the Sensu server and API system(s), and all systems running the Sensu client:

    {
      "rabbitmq": {
        "host": "10.0.1.6",
        "port": 5672,
        "vhost": "/sensu",
        "user": "sensu",
        "password": "secret"
      }
    }

 Install Rabbitmq

Summary 

Is this page helpful?