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

Sentinel mode and cluster mode in redis

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

Share

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

The editor in this issue will bring you about the sentinel mode and cluster mode in redis, and analyze and describe it from a professional point of view. I hope you can get something after reading this article.

Sentinel mode

It is a highly available solution, and sentinel itself is a stand-alone process that can be deployed to monitor Redis clusters on other machines that can communicate with Redis clusters.

Monitoring: the Sentinel will regularly monitor whether the redis is running well.

Reminder: if the Sentinel finds something wrong with a redis node, he can notify another process (such as his client).

Automatic failover: master / slave switchover occurs after master downtime. 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. If master is restored, it will become slave.

Redis Sentinel is a distributed system that uses Gossip protocol to receive master offline, uses voting protocol to decide whether to perform a failover (when the number of votes exceeds the configured value, and needs to be approved by more than half of the sentinels), and which slave is selected as the master.

Subjective offline: when a Sentinel process monitor master is unable to connect, he thinks master is offline.

Objective offline: when receiving master messages from other Sentinel processes, determine whether they are truly offline.

Each sentinel sends ping requests every second to master, slave, and other sentinels.

Cluster mode

Since the Sentinel does not support smooth expansion and increase the number of nodes, you have to migrate the data manually. To this end, Reids officially provides Redis Cluster to implement a distributed solution. The distributed cluster mainly solves the problem of mapping the whole data set to multiple nodes according to the partition rules, that is, dividing the data set into multiple nodes, and each node is responsible for a subset of the whole data.

I think it's the same as consistent hash. Now that the hash of key is calculated and the shards are obtained, the disadvantage of cluster mode is that the batch operation of key cannot be carried out. Because this key may be on a different redis instance.

The fault discovery of the cluster is also notified to each redis node through Gossip, and the two nodes ping and pong each other.

Deleting and adding nodes requires data migration.

The above is the sentinel mode and cluster mode in redis shared by the editor. If you have similar doubts, it will not hinder your understanding with reference to the above analysis. If you want to know more about it, please follow the industry information.

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