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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Redis cluster mode deploys Redis instances to multiple servers through sharding, improving scalability and availability. The construction steps are as follows: Create odd Redis instances with different ports; Create 3 sentinel instances, monitor Redis instances and failover; configure sentinel configuration files, add monitoring Redis instance information and failover settings; configure Redis instance configuration files, enable cluster mode and specify the cluster information file path; create nodes.conf file, containing information of each Redis instance; start the cluster, execute the create command to create a cluster and specify the number of replicas; log in to the cluster to execute the CLUSTER INFO command to verify the cluster status; make

How to clear Redis data: Use the FLUSHALL command to clear all key values. Use the FLUSHDB command to clear the key value of the currently selected database. Use SELECT to switch databases, and then use FLUSHDB to clear multiple databases. Use the DEL command to delete a specific key. Use the redis-cli tool to clear the data.

To read a queue from Redis, you need to get the queue name, read the elements using the LPOP command, and process the empty queue. The specific steps are as follows: Get the queue name: name it with the prefix of "queue:" such as "queue:my-queue". Use the LPOP command: Eject the element from the head of the queue and return its value, such as LPOP queue:my-queue. Processing empty queues: If the queue is empty, LPOP returns nil, and you can check whether the queue exists before reading the element.

Use the Redis command line tool (redis-cli) to manage and operate Redis through the following steps: Connect to the server, specify the address and port. Send commands to the server using the command name and parameters. Use the HELP command to view help information for a specific command. Use the QUIT command to exit the command line tool.

Redis memory soaring includes: too large data volume, improper data structure selection, configuration problems (such as maxmemory settings too small), and memory leaks. Solutions include: deletion of expired data, use compression technology, selecting appropriate structures, adjusting configuration parameters, checking for memory leaks in the code, and regularly monitoring memory usage.

Redis counter is a mechanism that uses Redis key-value pair storage to implement counting operations, including the following steps: creating counter keys, increasing counts, decreasing counts, resetting counts, and obtaining counts. The advantages of Redis counters include fast speed, high concurrency, durability and simplicity and ease of use. It can be used in scenarios such as user access counting, real-time metric tracking, game scores and rankings, and order processing counting.

Using the Redis directive requires the following steps: Open the Redis client. Enter the command (verb key value). Provides the required parameters (varies from instruction to instruction). Press Enter to execute the command. Redis returns a response indicating the result of the operation (usually OK or -ERR).

Redis, as a message middleware, supports production-consumption models, can persist messages and ensure reliable delivery. Using Redis as the message middleware enables low latency, reliable and scalable messaging.
