Go RabbitMQ clusters with highly available configurations

Source: Internet
Author: User
Tags haproxy

    • Cluster overview
    • Environment
    • Configuration steps
Cluster overview Through the distributed nature of Erlang (through the Magic Cookie Authentication node) for the RabbitMQ cluster, each RabbitMQ service is a peer node, that is, each node provides services to the client connection for sending and receiving messages. These nodes replicate the message queue structure through the RabbitMQ HA queue (mirror queue). In this scenario, 3 nodes are built, and all are disk nodes (all node states are consistent and nodes are fully equal), so long as any one node can work, the RabbitMQ cluster can provide services to the outside. Environment
    • CentOS 6.4, 64-bit
    • RabbitMQ 3.1.5
    • HAProxy 1.4.22
The RabbitMQ cluster is installed on 3 nodes: 192.168.1.1, 192.168.1.2, 192.168.1.3;haproxy are installed on the 192.168.1.4 to provide RabbitMQ equalization externally. Download the required installation package. Configuration steps 1. Installing Erlang, RABBITMQInstall on the 192.168.1.1, 192.168.1.2, 192.168.1.3 three nodes, and then turn on the RabbitMQ monitoring plugin:
rabbitmq-plugins enablerabbitmq_management
2. Modify/etc/hostsDescription of the 3 nodes added to the cluster:
192.168.1.1 node1192.168.1.2 node2192.168.1.3 node3
3. Setting Up Erlang CookiesErlang 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
4. Run each node using the-detached parameter
# rabbitmqctl stop# rabbitmq-server -detached
5. Forming a clusterNode2, 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
At this point Node2 and Node3 also automatically establish a connection, and if you want to use a memory node, you can use Node2 # Rabbitmqctl Join_cluster --ram[Email protected] Join the cluster. After the cluster is configured, you can perform rabbitmqctl cluster_status on any node of RabbitMQ to see if the cluster configuration is successful. 6. Set the mirroring queue policyExecute 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. 7. Install and configure the HAProxyInstall HAProxy on 192.168.1.4, and then modify the/etc/haproxy/haproxy.cfg:
listen rabbitmq_cluster 0.0.0.0:5672mode tcpbalance roundrobinserver   node1 192.168.1.1:5672 check inter 2000 rise 2 fall 3  server   node2 192.168.1.2:5672 check inter 2000 rise 2 fall 3server   node2 192.168.1.3:5672 check inter 2000 rise 2 fall 3
----EOF----

Go RabbitMQ clusters with highly available configurations

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.