Redisl clusters of more than 3 improve the accuracy of fault judgment by increasing the number of sentinel nodes, because leader election requires at least half plus 1 node, and an odd number of nodes can be used on the basis of meeting this condition. Save a node.
To put it simply: if there are three nodes of sentinel, when a redis problem occurs, sentinel will immediately enter In voting, only if more than half of the votes are cast, the person will be offline! , and finally offline objectively, so 3 sentinel nodes are required. (Recommended learning: Redis video tutorial)
The sentinel mode is a special mode. First of all, Redis Sentinel commands are provided. Sentinel is an independent process. As a process, it will run independently. The principle is that the sentinel monitors multiple running Redis instances by sending commands and waiting for the Redis server to respond.
The sentry here has two functions
By sending commands, the Redis server returns to monitor its running status, including the master server and the slave server.
When Sentinel detects that the master is down, it will automatically switch the slave to the master, and then notify other slave servers through the publish and subscribe mode, modify the configuration file, and let them switch hosts.
However, problems may arise when a sentinel process monitors the Redis server. For this reason, we can use multiple sentinels for monitoring. Each sentinel will also be monitored, thus forming a multi-sentinel mode.
Describe the failover process in words.
Assume that the main server is down and Sentinel 1 detects this result first. The system will not immediately perform the failover process. It is just that Sentinel 1 subjectively believes that the main server is unavailable. This phenomenon becomes a subjective offline. When the subsequent sentinels also detect that the main server is unavailable and the number reaches a certain value, a vote will be held between the sentinels. The result of the vote will be initiated by one sentinel to perform a failover operation. After the switch is successful, each sentinel will use the publish-subscribe mode to switch the slave server it monitors to the host. This process is called objective offline. This way everything is transparent to the client.
For more Redis-related technical articles, please visit the Introduction to Using Redis Database Tutorial column to learn!
The above is the detailed content of Why are there more than three Redis clusters?. For more information, please follow other related articles on the PHP Chinese website!