Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


interworks.cloud platform - RabbitMQ Server

Deployment Guide

...


This chapter explains how to install RabbitMQ in a high available configuration (3-node cluster) . using an RPM-based installation on CentOS 8.x. as well as a windows-based installation.

RabbitMQ can be deployed using various configurations and different platforms (OS, H/W environments). You can find detailed information on installing and configuring RabbitMQ at: https://www.rabbitmq.com/download.html

...

  1. Connect to an available node (node01) with administrator (root) credentials

  2. Import RabbitMQ signing key
    rpm --import https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc

  3. Setup RabbitMQ repository that will install RabbitMQ 3.8 and targets CentOS 8
    Edit/create the file /etc/yum.repos.d/rabbitmq-bintray.repo and set the following content:

    [bintray-rabbitmq-server]
    name=bintray-rabbitmq-rpm
    baseurl=https://dl.bintray.com/rabbitmq/rpm/rabbitmq-server/v3.8.x/el/8/
    gpgcheck=0
    repo_gpgcheck=0
    enabled=1

  4. Install RabbitMQ
    dnf -y update
    dnf -y install epel-release telnet
    dnf -y install rabbitmq-server.noarch

  5. Connect to servers node02 and node03 and repeat steps 2, 3 and 4

  6. Start and Stop RabbitMQ server on node01
    systemctl start rabbitmq-server
    systemctl stop rabbitmq-server

  7. Copy the Erlang cookie from node 1 to nodes 2 and 3
    scp /var/lib/rabbitmq/.erlang.cookie root@<node02>:/var/lib/rabbitmq/
    scp /var/lib/rabbitmq/.erlang.cookie root@<node03>:/var/lib/rabbitmq/

  8. Assign appropriate permissions to .erlang.cookie on all servers (node01, node02 and node03)
    chown rabbitmq:rabbitmq /var/lib/rabbitmq/.erlang.cookie
    chmod 400 /var/lib/rabbitmq/.erlang.cookie

  9. Enable the RabbitMQ server service on all servers (node01, node02 and node03)
    systemctl enable rabbitmq-server
    rabbitmq-plugins enable rabbitmq_management

  10. Create the cluster (Start the RabbitMQ server on node01)
    systemctl start rabbitmq-server

  11. Start the RabbitMQ server on servers node02 and node02
    systemctl start rabbitmq-server -detached

  12. Initial cluster configuration (Add administrator user and create basic policies on node01)
    rabbitmqctl add_user <rabbitadmin> <rabbitadminpassword>
    rabbitmqctl set_user_tags <rabbitadmin> administrator
    rabbitmqctl set_permissions -p / <rabbitadmin> “.*” “.*” “.*”
    rabbitmqctl delete_user guest
    rabbitmqctl list_users
    rabbitmqctl set_policy ha-all “.*” ‘{“ha-mode”:”all”}'

  13. Check the cluster status (node01)
    rabbitmqctl cluster_status

  14. Add the rest of the nodes to the cluster. On each node (node02 and node03) execute the following commands:
    rabbitmqctl stop_app
    rabbitmqctl reset
    rabbitmqctl join_cluster rabbit@<node01>
    rabbimqctl start_app

  15. Check the cluster status again and verify all three (3) nodes have joined the cluster.
    rabbitmqctl cluster_status


5.2. RabbitMQ configuration (linux-based)

...

  1. Connect to an available node (node01) with administrative credentials

  2. Download the latest supported 64-bit Erlang version at the OTP Versions Tree page

  3. Download the installer for the latest stable release of RabbitMQ server at Github

  4. Set the following system-wide environment variables on the server:
    ERLANG_HOME = C:\Program Files\erl
    RABBITMQ_BASE = C:\RabbitMQ
    RABBITMQ_CONFIG_FILE = %RABBITMQ_BASE%
    RABBITMQ_NODENAME = rabbit@NODE01

    Note: Depending on the server host name you should also set the RABBITMQ_NODENAME environment variable as needed. For example if the server host name is srvrab01 then the variable should be set as RABBITMQ_NODENAME = rabbit@SRVRAB01

  5. Restart the server node01

  6. Install Erlang OTP using as installation path the path you set for the ERLANG_HOME environment variable in step 4
    Important: You must use an administrative account and install the software as an administrator (… run as administrator)

  7. Install RabbitMQ Server using the default installation options
    Important: You must use an administrative account and install the software as an administrator (… run as administrator)
    Note: If you are installing a second or subsequent node (node02, node03, and so forth) copy the original cookie located on the first node (node01) at C:\Windows\System32\config\systemprofile\.erlang.cookie to the same location of the current node (overwrite if asked)

  8. Add C:\Program Files\RabbitMQ Server\rabbitmq_server-A.B.CD\sbin to path system environment variable, where A.B.CD is the release version of the RabbitMQ Server you downloaded in step 3 (e.g.: 3.8.19)

  9. Launch an elevated command prompt and run the following command:
    rabbitmqctl status

    If you encounter the error “[error] Failed to create cookie file 'h:/.erlang.cookie': enoent“ please proceed with the following actions:

    1. Edit the file C:\Program Files\RabbitMQ Server\rabbitmq_server-A.B.CD\sbin\rabbitmq-env.bat and locate the section

      REM Environment cleanup
      set BOOT_MODULE=
      set CONFIG_FILE=
      set FEATURE_FLAGS_FILE=
      set ENABLED_PLUGINS_FILE=
      set LOG_BASE=
      set MNESIA_BASE=
      set PLUGINS_DIR=
      set SCRIPT_DIR=
      set SCRIPT_NAME=
      set TDP0=

      Directly beneath this section insert a new line with the following content:
      set HOMEDRIVE=C:\RabbitMQ

    2. Copy C:\Windows\System32\config\systemprofile\.erlang.cookie to C:\rabbitmq (overwrite if asked)

    3. Run the following commands on an elevated command prompt to re-install the RabbitMQ service:
      rabbitmq-service stop
      rabbitmq-service remove
      rabbitmq-service install
      rabbitmq-service start

    4. Verify service is started and is operational by running the following commands on an elevated command prompt:
      rabbitmqctl start_app
      rabbitmqctl status

  10. Create a user (rabbitadmin) with administrative privileges by running the following commands on an elevated command prompt:
    rabbitmqctl add_user rabbitadminsome_random_password
    rabbitmqctl set_user_tags rabbitadmin administrator
    rabbitmqctl set_permissions -p / rabbitadmin "." "." ".*"
    Note: You must not run these commands on subsequent nodes, since you will be forming a cluster and you will be accessing all cluster nodes using this specific set of credentials

  11. Enable the management plugin by running the following command on an elevated command prompt:
    rabbitmq-plugins enable rabbitmq_management
    Verify access to the management interface by navigating to the URL: http://node01:15672 on the server

  12. Configure the local server firewall by:

    1. Allowing incoming traffic to the following TCP ports: 5671, 5672, 4369, 25672, 35672-35682, 15672, 61613, 61614, 1883, 8883, 15674, 15675, 15692, 44002

    2. Allowing access to the following binaries:

      1. %ProgramFiles%\erl\bin\erl.exe (Erlang)

      2. %ProgramFiles%\erl\erts-X.Y.Z\bin\erl.exe (Erlang Run-Time System)

      3. %ProgramFiles%\erl\erts-X.Y.Z\bin\epmd.exe (Erlang Port Mapper Daemon)
        Note: X.Y.Z denotes the version of Erlang installed, make sure to check the path in order to get the correct version.

  13. In order to install the rest of the nodes repeat steps 1 to 12 (omitting step 10) for all other nodes (node02 and node03 in this tutorial)
    Important: Make sure to copy the original cookie (C:\Windows\System32\config\systemprofile\.erlang.cookie) from the first node (node01) to the other nodes at Step 7

  14. Join node node02 to the cluster by executing the following commands on an elevated command prompt:
    rabbitmqctl stop_app
    rabbitmqctl reset
    rabbitmqctl join_cluster rabbit@NODE01
    rabbitmqctl start_app

  15. Join node node03 to the cluster by executing the following commands on an elevated command prompt:
    rabbitmqctl stop_app
    rabbitmqctl reset
    rabbitmqctl join_cluster rabbit@NODE01
    rabbitmqctl start_app

  16. Check the cluster status and verify all three (3) nodes have joined the cluster by executing the following command on an elevated command prompt:
    rabbitmqctl cluster_status

5.4. RabbitMQ configuration (windows-based)

...