Get the App
SLTechnology News&Howtos  ›  Development  › 

Basic knowledge arrangement of redis Sentinel Architecture

Shulou Source: shulou.com Published: 2022-06-03 18:54:00 10月03日 Update

This article introduces the relevant knowledge of "sorting out the basic knowledge of redis Sentinel Architecture". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. The introduction of the Sentinel

Sentinel, Chinese is Sentinel.

Sentinel is a very important component of redis cluster architecture, and its main functions are as follows:

(1) Cluster monitoring: responsible for monitoring whether reidis master and slave processes are working properly

(2) message notification: if a redis instance fails, the sentry is responsible for sending a message to the administrator as an alarm notification.

(3) failover: if the master node fails, it will be automatically transferred to the slave node.

(4) configuration Center: if a failover occurs, notify the client client of the new master address

The Sentinel itself is distributed as a Sentinel cluster to run and work together.

(1) during failover, it is necessary to determine that a master node is down, which requires the consent of most sentinels, which involves the issue of distributed election.

(2) even if some of the sentinel nodes are down, the Sentinel cluster can still work properly, because it would be ridiculous if the failover system itself, which is an important part of the high availability mechanism, is a single point. Sentinel2 version is currently used, and sentinel2 rewrites a lot of code compared to sentinel 1, mainly to make the failover mechanism and algorithm more robust and simple.

two。 The core knowledge of Sentinel

(1) Sentinels need at least 3 examples to ensure their robustness.

(2) the deployment architecture of Sentinel + redis master-slave does not guarantee the loss of data 0, but can only ensure the high availability of redis clusters.

(3) for the responsible deployment architecture of Sentinel + redis master-slave, try to conduct adequate tests and drills in both test and production environments.

3. Why is only 2 nodes in the redis Sentinel cluster not working properly?

The Sentinel cluster must deploy more than 2 nodes. If the Sentinel cluster only deploys 2 Sentinel instances, quorum=1

M1 R1

S1 S2

Configuration:quorum = 1 (Sentinel node can be switched if only one node thinks it is down)

Master is down. As long as one sentry in S1 and S2 thinks it is down, it can be switched over. At the same time, one sentry in S1 and S2 will be elected for failover. At this time, majority, that is, most sentinels are running. The majority of two sentinels, that is, two sentinels running here, can be allowed to perform failover, but the whole M1 and S2 running machines are down, so there is only one sentry left. There is no majority to allow failover, and although the other machine has an R1, the failover will not be performed

4. Classic 3-node Sentinel Cluster

M1

S1

R2 R3

S2 S3

Configuration:quorum = 2 majoiry

If the machine on which M1 is located is down, there are two of the three sentinels left. S2 and S3 can agree that master is down, and then choose one to perform the failover; at the same time, the majoiry of the three sentinels is 2, so there are two sentinels left to fail over.

This is the end of the introduction to the basics of the redis Sentinel Architecture. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Sentinel fault cluster architecture knowledge node run work at the same time instance machine guarantee election foundation basic knowledge robust important master-slave content distributed Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Tech Info Linux Huawei Shulou Information