[1] Architecture introduction
- Ordinary cluster: active-standby architecture, just to implement the active-standby solution, so that the main node will not be down and the entire service will not be available
- Mirror cluster: synchronization structure, queue synchronization based on common cluster implementation
(1.1) rabbitmq master-slave cluster
The slave node replicates all data and state of the master node, except for queue data;
The queue data only exists on the master node, but the Rabbitmq slave node can realize the forwarding of the queue, that is to say, the message consumer can connect to the slave node, but the slave needs to connect to the master node forwarding queue;
This shows that the service can only be guaranteed to be available, and high availability cannot be achieved.
The slave node queue can be viewed, but the data will not be synchronized
Master-slave architecture cluster:
The slave node can back up the switches and queues of the master node, but cannot back up the messages in the queue of the slave node. That is to say, once the master node goes down, the slave node only has the queue name, but the messages in the queue also No, it is impossible to achieve a state of high availability
Access via browser: If the page fails to get up, run the command rabbitmq-plugins enable rabbitmq _management to start its page management plugin
(1.2) rabbitmq mirroring high availability cluster
Someone asked about the high-availability method of rabbitmq today, because it is a bit different from the common master-slave mode, so I will record it.
The mirror queue of the rabbitmq cluster provides a higher level of master-slave backup, which is the master-slave queue of each other:
rabbitmq-server provides clients with access to any of the nodes to obtain metadata of the entire cluster, so producers and consumers can intuitively see which machine in the cluster is connected to, but it is certain that the main queue receives Messages routed by exchange and pushed to consumers cannot be received from the slave queue; however, the slave queue can receive messages synchronized from the main queue and provide them to consumers.
In summary, it is the role of the master-slave queue of rabbitmq: the master queue provides the ability to read and write messages, and the slave queue only provides the ability to read messages. So how do you understand the master-slave queues that are master and slave?
Look at a picture first:
This is a cluster composed of three machines. The ha-mode is all (exactly recommended by the official website of rabbitmq, and ha-params=N/2 1, which is set to all for the convenience of later explanation), rabbitmq provides a complete management interface ;
When the queue1 queue is created, which node in the cluster can be selected by node, the default is the current machine logged in. In order to disperse machine pressure and improve performance, when creating queues, the main queues are distributed and built on different machines.
Because the mirror queue parameter is set to all, queue1 will automatically synchronize the metadata of queue1 to the other two machines. Similarly, queue2 and queue3 created on other machines will form the deployment structure in the above figure.
For queue1, machine 1 is the master, and machines 2 and 3 are slaves; for queue2, machine 2 is the master, and machines 1 and 3 are slaves; for queue3, machine 3 is the master, and machines 1 and 2 are slaves; in this way, machine 1 is viewed as a whole. , 2, 3 are masters and backups of each other, which disperses the pressure on the cluster, provides the rate of sending messages, and also improves the high availability of the cluster.
Rabbitmq_prometheus monitoring plugin
One of Rabbitmq’s plugins is rabbitmq_prometheus. When this plugin is enabled, rabbitmq-sever will open a port of 15692 to provide prometheus to obtain monitoring information;
Access the monitoring information by visiting the link: http://ip:15692/metrics. The prometheus official website also provides the rabbitmq_exporter plug-in. If the rabbitmq_prometheus plug-in is enabled, the rabbitmq_exporter plug-in is not needed, and the monitoring information obtained by the rabbitmq_prometheus plug-in is far greater than the information obtained by the exporter. So it is recommended to use the rabbitmq_prometheus plugin.
Cluster related parameters and strategies:
…
The post rabbitmq high availability, rabbitmq master-slave, rabbitmq mirror first appeared on Lenix Blog .
This article is reprinted from https://blog.p2hp.com/archives/9101
This site is for inclusion only, and the copyright belongs to the original author.