Setting up RabbitMQ for a High-Availability Spok Mobile Implementation
See also: Setting up a Highly Available Spok Mobile Environment
Make Sure Erlang Cookies Match on Primary and Secondary Spok Mobile Servers
- On the primary Spok Mobile server, locate the two
.erlang.cookie
files. Copy both of them.
With Erlang versions starting with 20.2, the cookie file locations are:%HOMEDRIVE%%HOMEPATH%\.erlang.cookie
(usuallyC:\Users\%USERNAME%\.erlang.cookie
)%USERPROFILE%\.erlang.cookie
(usuallyC:\WINDOWS\system32\config\systemprofile
)
- Stop the RabbitMQ windows service on the secondary Spok Mobile server.
- Paste the
.erlang.cookie
files that you copied from the primary Spok Mobile server into the same locations on the secondary Spok Mobile server:%HOMEDRIVE%%HOMEPATH%\.erlang.cookie
(usuallyC:\Users\%USERNAME%\.erlang.cookie
)%USERPROFILE%\.erlang.cookie
(usuallyC:\WINDOWS\system32\config\systemprofile
)
- Open the files on both servers to verify that the content is the same. Both instances of RabbitMQ should now have the same
.erlang.cookie
files. - Start the RabbitMQ windows service on the secondary Spok Mobile Server.
Determine the RabbitMQ Nodes on the Primary and Secondary Spok Mobile Servers
In the following procedure, you will be executing rabbitmqctl
command line commands for RabbitMQ. For more details, see https://www.rabbitmq.com/rabbitmqctl.8.html.
-
Оn the primary Spok Mobile Server, open a command prompt with Administrator rights, and navigate to RabbitMQ’s
sbin
folder (usuallyC:\Program Files\RabbitMQ Server\rabbitmq_server-3.7.0\sbin
for RabbitMQ 3.7.0 andC:\Program Files\RabbitMQ Server\rabbitmq_server-3.8.3\sbin
for RabbitMQ 3.8.3). -
Run the following command to check the current state of the clusters on the primary Spok Mobile server:
rabbitmqctl cluster_status
This should return the following (in this example, rabbit@SM-FT-45 is the RabbitMQ node of the primary Spok Mobile server):
Cluster status of node rabbit@SM-FT-45 ... [{nodes,[{disc,['rabbit@SM-FT-45']}]}, {running_nodes,['rabbit@SM-FT-45']}, {alarms,[{'rabbit@SM-FT-45',[]}]}]
-
Run the following command to check the current state of the clusters on the secondary Spok Mobile server:
rabbitmqctl cluster_status
This should return the following (in this example, rabbit@SM-2-FT-45 is the RabbitMQ node of the secondary Spok Mobile server):
Cluster status of node rabbit@SM-2-FT-45 ... [{nodes,[{disc,['rabbit@SM-2-FT-45']}]}, {running_nodes,['rabbit@SM-2-FT-45']}, {alarms,[{'rabbit@SM-2-FT-45',[]}]}]
Join the Primary and Secondary Spok Mobile Servers in a Cluster
-
Stop the secondary Spok Mobile server RabbitMQ node by running the following command:
rabbitmqctl stop_app
-
After the Rabbit application is stopped on the secondary Spok Mobile server node (rabbit@SM-2-FT-45 in this example), run the following command to create the cluster:
rabbitmqctl join_cluster rabbit@SM-FT-45
-
Start the secondary Spok Mobile server’s node by running the following command:
rabbitmqctl start_app
-
Check the cluster status of the secondary and primary Spok Mobile Servers by running the following command on each:
rabbitmqctl cluster_status
Both servers should return the following:
Cluster status of node rabbit@SM-2-FT-45 ... [{nodes,[{disc,['rabbit@SM-2-FT-45','rabbit@SM-FT-45']}]}, {running_nodes,['rabbit@SM-FT-45','rabbit@SM-2-FT-45']}, {cluster_name,<<"rabbit@SM-FT-45.spokvdev.com">>}, {partitions,[]}, {alarms,[{'rabbit@SM-FT-45',[]},{'rabbit@SM-2-FT-45',[]}]}]
There are now two nodes running in the cluster. If you open the Management UI on http://localhost:15672, you will see the cluster name on the top right corner of the UI.
-
Now when you open RabbitMQ Web Management (http://localhost:15672) on one of the servers, the changes will be preserved on both nodes. For more information about the RabbitMQ Web Management, see https://www.rabbitmq.com/management.html.
Configuring the Spok Mobile Load Balancer for RabbitMQ
Customers are responsible for configuring and managing load balancers for the Spok Mobile solution. The Spok Mobile load balancer must direct traffic from port 8883
to the Spok Mobile servers. The RabbitMQ instances listen on this port.