esyede
You need minimum 2 servers with private network for setting up a cluster . Below steps assumes that you have 3 vps on same private network.
- Setup hostname on each node with all node details like below (You need Private IP for this)
(192.168.1.101 rabbit1
192.168.1.102 rabbit2
192.168.1.103 rabbit3 ) and check ping to make sure that each servers are accessible using hiostname.
- Install Rabbit MQ on all nodes and check the server running status using terminal or AApanel.
- Edit the RMQ config files and add loopback_users configuration includes an empty list ([]) or omits the default 'guest' user to allow remote access. (loopback_users.guest = false)
- To create a RabbitMQ cluster, you’ll set up a .erlang.cookie file in each server with the same content and must be owned by the rabbitmq user and group. On the node01 server check available files on the RabbitMQ data directory (/var/lib/rabbitmq). and copy the content of .erlang.cookie file. Now stop node 2 and node 3 and past the erlang.cookie content of node 1 to both node 2 and node 3 server. Then restart all the nodes.
- Run following command on node 2 and node 3 to join node 1 cluster
Stop RabbitMQ application
sudo rabbitmqctl stop_app
Join the RabbitMQ node01
sudo rabbitmqctl join_cluster rabbit@node01
Start the RabbitMQ application again
sudo rabbitmqctl start_app
- FInally check the status of the cluster with sudo rabbitmqctl cluster_status
After setting up the RabbitMQ cluster, you’ll create a new admin user for RabbitMQ and delete the default guest user. The RabbitMQ admin user has permission to configure, read, and write any entity available on the RabbitMQ cluster.