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
...
Connect to an available node (node01) with administrator (root) credentials
Import RabbitMQ signing key
rpm --import https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.ascSetup 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=1Install RabbitMQ
dnf -y update
dnf -y install epel-release telnet
dnf -y install rabbitmq-server.noarchConnect to servers node02 and node03 and repeat steps 2, 3 and 4
Start and Stop RabbitMQ server on node01
systemctl start rabbitmq-server
systemctl stop rabbitmq-serverCopy 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/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.cookieEnable the RabbitMQ server service on all servers (node01, node02 and node03)
systemctl enable rabbitmq-server
rabbitmq-plugins enable rabbitmq_managementCreate the cluster (Start the RabbitMQ server on node01)
systemctl start rabbitmq-serverStart the RabbitMQ server on servers node02 and node02
systemctl start rabbitmq-server -detachedInitial 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”}'Check the cluster status (node01)
rabbitmqctl cluster_statusAdd 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_appCheck the cluster status again and verify all three (3) nodes have joined the cluster.
rabbitmqctl cluster_status
5.2. RabbitMQ configuration (linux-based)
...
Connect to an available node (node01) with administrative credentials
Download the latest supported 64-bit Erlang version at the OTP Versions Tree page
Download the installer for the latest stable release of RabbitMQ server at Github
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@SRVRAB01Restart the server node01
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)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)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)
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: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:\RabbitMQCopy C:\Windows\System32\config\systemprofile\.erlang.cookie to C:\rabbitmq (overwrite if asked)
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 startVerify service is started and is operational by running the following commands on an elevated command prompt:
rabbitmqctl start_app
rabbitmqctl status
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 credentialsEnable 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 serverConfigure the local server firewall by:
Allowing incoming traffic to the following TCP ports: 5671, 5672, 4369, 25672, 35672-35682, 15672, 61613, 61614, 1883, 8883, 15674, 15675, 15692, 44002
Allowing access to the following binaries:
%ProgramFiles%\erl\bin\erl.exe (Erlang)
%ProgramFiles%\erl\erts-X.Y.Z\bin\erl.exe (Erlang Run-Time System)
%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.
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 7Join 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_appJoin 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_appCheck 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)
...