Ensure the successful installation of JDK,ERLANG,RABBITMQ and so on, and RABBITMQ can start normally, multiple computers can ping each other through.
1. Installing erlang,rabbitmq
such as: 192.168.1.1, 192.168.1.2, 192.168.1.3 three nodes installed, and then turn on the RabbitMQ monitoring plug-in:
Rabbitmq-plugins Enable Rabbitmq_management Reference blog: Http://88250.b3log.org/rabbitmq-clustering-ha http://blog.csdn.net/gao715108023/article/details/11522889 |
2. Modify host name
Vi/etc/hosts Make sure that the contents of each host Hosts file are modified as follows: IP host name
such as: 10.111.56.134 Master
10.111.56.79 Slave5
3. Setting up Erlang cookies
Erlang Cookie file:/var/lib/rabbitmq/.erlang.cookie. Here will node1 the file copy to Node2, Node3, because this file permissions is 400, so you need to first modify the Node2, node3 the file permission is 777:
# chmod 777/var/lib/rabbitmq/.erlang.cookie |
Then copy the file in Node1 to Node2, NODE3, and finally modify the permissions and the owning user/group back:
# chmod 400/var/lib/rabbitmq/.erlang.cookie # chown Rabbitmq/var/lib/rabbitmq/.erlang.cookie # CHGRP Rabbitmq/var/lib/rabbitmq/.erlang.cookie |
Also ensure that the contents of the hidden file/root/.erlang.cookie are consistent, it is best to test the master node on the other node host.
4. Run each node using the -detached parameter
# Rabbitmqctl Stop # rabbitmq-server-detached |
5. forming a cluster
Node2, Node3, and Node1 are organized into clusters:
Node2 # Rabbitmqctl Stop_app Node2 # rabbitmqctl Join_cluster [email protected] Node2 # Rabbitmqctl Start_app NODE3 # Rabbitmqctl Stop_app NODE3 # rabbitmqctl Join_cluster [email protected] NODE3 # Rabbitmqctl Start_app |
To view the RABBITMQ process:
The cluster node is added.
Node2 and Node3 also automatically establish a connection, and if you want to use a memory node, you can use the
Node2 # rabbitmqctljoin_cluster --ram [email protected] Join the cluster.
After the cluster is configured, you can perform rabbitmqctlcluster_status on any node of RabbitMQ to see if the cluster configuration is successful.
6. Set the mirroring queue policy
Execute on any of the nodes:
# rabbitmqctl Set_policy ha-all "^" ' {"Ha-mode": "All"} ' |
All queues are set to the mirror queue, that is, the queues are copied to each node, and the state of each node remains.
After completing these 6 steps, the RabbitMQ high-availability cluster has been set up, and the last step is to build the equalizer.
RABBITMQ Cluster Environment Construction-4