Home > Database > Redis > body text

Why add redis sentry mode

silencement
Release: 2019-06-06 14:38:28
Original
3502 people have browsed it

Why add redis sentry mode

Introduction to Redis Sentinel

The Sentinel process is used to monitor the working status of the Master server in the redis cluster. On the Master server When a failure occurs, the Master and Slave servers can be switched to ensure the high availability of the system. It has been integrated in the redis version 2.6. The sentinel mode of Redis has stabilized since version 2.8. Generally, it is recommended to use Redis version 2.8 or later in a production environment. Sentinel is a distributed system. You can run multiple sentinel processes in an architecture. These processes use gossip protocols to receive information about whether the Master server is offline and use voting protocols ( Agreement Protocols) to decide whether to perform automatic failover and which Slave to choose as the new Master. Each Sentinel process will regularly send messages to other Sentinels, Master, and Slave to confirm whether the other party is "alive". If it is found that the other party has not received a response within the specified configuration time (configurable), it will temporarily Thinking that the other party has been offline is the so-called "subjective belief that it is down". The English name is: Subjective Down, or SDOWN for short. If there is subjective downtime, there must be objective downtime. When most of the Sentinel processes in the "Sentinel Group" make SDOWN judgments on the Master server and communicate with each other through the SENTINEL is-master-down-by-addr command, the Master Server is offline judged in this way. It is "objective downtime", the English name is: Objectively Down, or ODOWN for short. Through a certain vote algorithm, one of the remaining slave server nodes is selected to be promoted to the Master server node, and then the relevant configurations are automatically modified and failover is enabled.

Although Sentinel has a separate executable file redis-sentinel, it is actually just a Redis server running in a special mode. You can pass the given - when starting a normal Redis server. -sentinel option to start sentinel. Some design ideas of sentinel are very similar to zookeeper.

Sentinel clusters will communicate with each other, communicate the status of redis nodes, make corresponding judgments and process them. The subjective offline status and objective offline status here are more important statuses. They determine Whether to perform failover can be done by subscribing to the specified channel information and notifying the administrator when the server fails. The client can regard Sentinel as a Redis server that only provides subscription functions. You cannot use the PUBLISH command to send messages to this server. Send information, but you can use the SUBSCRIBE command or PSUBSCRIBE command to get corresponding event reminders by subscribing to a given channel. A channel can receive events with the same name as the channel. For example, a channel named sdown can receive events when all instances enter the subjective offline (SDOWN) state.

The role of the Sentinel process:

1. Monitoring: Sentinel will constantly check whether your Master and Slave are operating normally.

2. Notification: When a problem occurs on a monitored Redis node, the sentinel can send notifications to the administrator or other applications through the API.

3. Automatic failover: When a Master cannot work properly, Sentinel will start an automatic failover operation. It will upgrade one of the Slaves of the failed Master to a new Master. , and let other Slaves of the failed Master change to copy the new Master; 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 the current Master to replace the failed Master. After the Master and Slave servers are switched, the contents of the Master's redis.conf, Slave's redis.conf and sentinel.conf configuration files will change accordingly, that is, there will be an extra line of slaveof in the Master's redis.conf configuration file. Configuration, the monitoring target of sentinel.conf will be changed accordingly

The above is the detailed content of Why add redis sentry mode. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template