Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the Sentinel in redis?

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article is to share with you about the sentinel mechanism in redis. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

High availability of redis: if you deploy master / slave architecture, you can simply add a sentinel. If any instance goes down, the master / slave switch will be carried out automatically.

Sentinel mechanism

With the implementation of master-slave replication, if you want to monitor the master server, a "sentry" mechanism is provided after redis2.6. As the name implies, the meaning of Sentinel is to monitor the operation of the redis system. Multiple sentinels can be started to monitor the running status of the redis database. Its main functions are as follows:

A. Monitor whether all node databases are running normally.

B. When the master database fails, it can automatically select a new master from the slave node through the voting mechanism, and realize the automatic switching of the conversion from the database to the master database.

In an one-master and multi-slave Redis system, multiple sentinels can be used for monitoring tasks to ensure that the system is robust enough. At this point, not only will the Sentinels monitor both the master database and the slave database, but the Sentinels will also monitor each other. Here, it is recommended that you deploy at least 3 sentinels and use an odd number of sentinels.

Redis's sentinel system, which manages multiple Redis servers, performs the following three tasks:

Monitoring: the sentinel will constantly check to see if your Master and Slave are working properly.

Notification: when there is a problem with a monitored Redis, the sentinel can send a notification to the administrator or other application through API.

Automatic failover (Automatic failover): when a Master does not work properly, the sentinel starts an automatic failover operation, which upgrades one of the Slave of the failed Master to the new Master and causes the other Slave of the failed Master to copy the new Master; instead. When the client tries to connect to the failed Master, the cluster will also return the address of the new Master to the client, so that the cluster can use Master instead of the failed Master.

Sentinel is a distributed system where you can run multiple sentinel processes in a single architecture. These processes use the rumor protocol (gossipprotocols) to receive information about whether the Master is offline or not, and use the voting protocol (agreement protocols) to decide whether to perform automatic failover and which Slave to choose as the new Master.

Each sentinel sends regular messages to other sentinel, master, and slave to confirm whether the other person is "alive". If he finds that the other person does not respond within a specified time (configurable), he temporarily thinks that the other person has hung up (the so-called "subjective downtime" Subjective Down, referred to as sdown).

If most of the sentinel in the "Sentinel Group" report that a certain master is not responding, the system thinks that the master is "completely dead" (that is, the objective real downmachine, Objective Down, referred to as odown). Through a certain vote algorithm, one of the remaining slave nodes is promoted to master, and then the relevant configuration is automatically modified.

Although sentinel is released as a separate executable redis-sentinel, it is really just a Redis server running in a special mode, and you can start sentinel with the-- sentinel option when starting a normal Redis server.

The above is the sentinel mechanism in redis, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report