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 difference between a redis cluster and a Sentinel

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

Share

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

This article will explain in detail what is the difference between redis clusters and sentinels. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

What's the difference between redis clusters and Sentinels?

The role of the Sentinel is to monitor the operation of the Redis system. Its functions include the following two.

Monitor whether the master database and slave database are running properly.

When the master database fails, the slave database is automatically converted to the master database.

When sentinel discovers that master is dead, it re-elects a master from slave.

Sentinel mode emphasizes high availability

The Sentinel system is used to manage multiple Redis servers (instance) and performs the following three tasks:

Monitoring (Monitoring): Sentinel will constantly check whether your master server and slave server are working properly.

Reminder (Notification): when there is a problem with a monitored Redis server, Sentinel can send notifications to administrators or other applications through API.

Automatic failover (Automatic failover): when a master server does not work properly, Sentinel starts an automatic failover operation, which upgrades one of the slaves of the failed master server to the new master server and allows the other slave servers of the failed master server to replicate the new master server When the client tries to connect to the failed primary server, the cluster also returns the address of the new primary server to the client, so that the cluster can use the new primary server instead of the failed server.

The client will not record the address of redis (an IP), but the address of sentinel, so that we can obtain the redis address directly from sentinel, because sentinel will monitor all master and slave, and it knows who the real master is. For example, when we fail over, for sentinel, master is changed, and then notify the client. On the other hand, the client doesn't care who the real master is at all, only the master told by sentinel.

Cluster

Even with Sentinel, each instance of redis is fully stored, and the content of each redis is complete data, which is a waste of memory and has a bucket effect. In order to maximize the use of memory, you can use clustering, that is, distributed storage. That is, each redis stores different content, with a total of 16384 slot. Each redis is assigned some slot,hash_slot = crc16 (key) mod 16384 to find the corresponding slot. The key is an available key. If there is {}, take the key within {} as the available key, otherwise the whole key is available.

The cluster needs at least 3 masters and 3 slaves, and each instance uses a different configuration file. The master and slave do not need to be configured, and the cluster will choose its own.

Cluster is to solve the problem of limited Redis capacity of a single machine, which distributes data to multiple machines according to certain rules.

Cluster mode increases concurrency.

So much for sharing the difference between redis cluster and Sentinel. I hope the above content can help you and learn more. If you think the article is good, you can share it for more people to see.

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