0Pricing
Redis Caching & Messaging (Pub/Sub, Streams) · Leçon

Redis Sentinel pour la haute disponibilité

Configurez Redis Sentinel pour gérer automatiquement le basculement et garantir la disponibilité continue du service.

Redis Sentinel pour la haute disponibilité est une leçon Redis Caching & Messaging (Pub/Sub, Streams) gratuite sur CoddyKit. Ceci est la leçon 2 sur 4. Tu peux lire la leçon complète ci-dessous gratuitement — puis la pratiquer en direct dans le navigateur avec un éditeur de code intégré et un tuteur IA 24/7. Elle fait partie du parcours d'apprentissage Redis Caching & Messaging (Pub/Sub, Streams), et ta progression se synchronise sur le web et l'application CoddyKit. Le cours Redis Caching & Messaging (Pub/Sub, Streams) comprend 4 leçons au total.

Certaines parties de cette leçon n'ont pas encore été traduites et s'affichent en anglais.

High Availability with Sentinel

When using Redis replication, what happens if your master server suddenly fails? Your application might go down!

This is where Redis Sentinel comes in. It's designed to make your Redis deployments highly available by automatically handling master failures.

Sentinel's Key Roles

Redis Sentinel isn't just one process; it's a distributed system of Sentinel instances. Each Sentinel has three main jobs:

  • Monitoring: Constantly checks if your master and replica instances are working correctly.
  • Notification: Alerts system administrators or other computer programs when a monitored Redis instance goes wrong.
  • Automatic Failover: If a master fails, Sentinel can start a failover process where a replica is promoted to master, and other replicas are reconfigured.

Sentinel Architecture Overview

A typical Sentinel setup involves:

  • One Redis master instance.
  • One or more Redis replica instances.
  • At least three Sentinel instances running on separate servers.

The Sentinels constantly communicate with each other and with the Redis instances to maintain a consistent view of the system's health.

Configuring a Sentinel

Each Sentinel instance needs a configuration file, typically named sentinel.conf. Here's a basic example. The key directive is sentinel monitor:

  • mymaster: The name you give your master set.
  • 127.0.0.1 6379: The master's IP and port.
  • 2: The quorum, explained next.
# Example sentinel.conf
port 26379
daemonize yes

# Monitor the master named 'mymaster'
sentinel monitor mymaster 127.0.0.1 6379 2

# How long a master must be unreachable before marked DOWN
sentinel down-after-milliseconds mymaster 5000

# Timeout for failover operations
sentinel failover-timeout mymaster 60000

Understanding Quorum

The quorum (the 2 in our config) is a crucial concept. It's the minimum number of Sentinels that must agree that a master is down before a failover process can be initiated.

This prevents a single Sentinel (or a network issue affecting only one Sentinel) from triggering an unnecessary failover, ensuring reliability.

Launching a Sentinel Instance

Once your sentinel.conf file is ready, you can start a Sentinel instance using the redis-sentinel command, pointing it to your config file.

You would typically run multiple Sentinels on different machines for true high availability.

redis-sentinel /path/to/sentinel.conf

Monitoring with Sentinel CLI

You can connect to a Sentinel instance using redis-cli (using the Sentinel's port, e.g., 26379) and query its status. The info sentinel command provides a wealth of information.

redis-cli -p 26379 info sentinel

The Failover Process in Action

When a master fails:

  1. Sentinels detect the master is unreachable.
  2. If enough Sentinels (the quorum) agree, they elect a leader Sentinel.
  3. The leader Sentinel promotes one of the healthy replicas to be the new master.
  4. The other replicas are reconfigured to replicate from the new master.
  5. Applications are notified of the new master's address.

Client Connectivity with Sentinel

Applications don't connect directly to the Redis master's IP and port. Instead, they are configured to connect to one or more Sentinel instances.

The client library then asks Sentinel for the current master's address. This means applications don't need to be reconfigured manually after a failover; Sentinel handles it transparently!

Sentinel Feature Check

Which of the following is NOT a primary function of Redis Sentinel?

Sentinel Recap & Next Steps

You've learned that Redis Sentinel is essential for creating highly available Redis deployments. It monitors your instances, performs automatic failovers, and keeps your applications connected even when a master goes down.

By using Sentinel, you significantly reduce downtime and improve the resilience of your Redis-backed applications. Next, we'll explore Redis Cluster for even greater scalability!

Questions Fréquemment Posées

La leçon « Redis Sentinel pour la haute disponibilité » est-elle gratuite ?

Oui — le texte complet de « Redis Sentinel pour la haute disponibilité » est gratuit à lire ici sur le web. Pour la pratiquer de manière interactive (un éditeur de code intégré et un tuteur IA 24/7) et déverrouiller le reste du cours Redis Caching & Messaging (Pub/Sub, Streams), passe à CoddyKit PRO. Le cours Redis Caching & Messaging (Pub/Sub, Streams) comprend 4 leçons au total.

Qu'est-ce que j'apprendrai dans « Redis Sentinel pour la haute disponibilité » ?

Configurez Redis Sentinel pour gérer automatiquement le basculement et garantir la disponibilité continue du service. Tu pratiques Redis Caching & Messaging (Pub/Sub, Streams) avec du code pratique que tu exécutes directement dans le navigateur, et un tuteur IA 24/7 répond à tes questions au fur et à mesure que tu avances dans la leçon.

Dois-je avoir de l'expérience pour commencer Redis Caching & Messaging (Pub/Sub, Streams) ?

Aucune expérience préalable n'est requise. Redis Caching & Messaging (Pub/Sub, Streams) sur CoddyKit est structuré pour les débutants jusqu'aux apprenants avancés, donc tu peux commencer ici ou depuis le début et avancer à ton rythme. Ceci est la leçon 2 sur 4.

Combien de temps prend la leçon « Redis Sentinel pour la haute disponibilité » ?

La plupart des leçons CoddyKit prennent environ 5–10 minutes. Chacune est courte et interactive, tu progresses régulièrement et tu repiques exactement où tu t'es arrêté sur le web et l'app.

Peux-tu écrire et exécuter du code dans cette leçon Redis Caching & Messaging (Pub/Sub, Streams) ?

Oui. Chaque leçon Redis Caching & Messaging (Pub/Sub, Streams) inclut un éditeur de code intégré, tu écris et exécutes du vrai code directement dans ton navigateur et tu reçois des retours IA instantanés — aucune configuration locale requise.

Toutes les leçons de ce cours

  1. Réplication Redis pour la redondance
  2. Redis Sentinel pour la haute disponibilité
  3. Redis Cluster pour le partitionnement horizontal
  4. Résilience des connexions côté client
← Retour à Redis Caching & Messaging (Pub/Sub, Streams)