0Pricing
Redis Caching & Messaging (Pub/Sub, Streams) · レッスン

高可用性のための Redis Sentinel

Redis Sentinel を設定し、フェイルオーバーを自動管理してサービスの継続的な可用性を確保します。

「高可用性のための Redis Sentinel」はCoddyKit上の無料Redis Caching & Messaging (Pub/Sub, Streams)レッスンです。 これはレッスン2/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはRedis Caching & Messaging (Pub/Sub, Streams)学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Redis Caching & Messaging (Pub/Sub, Streams)コースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

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!

よくある質問

「高可用性のための Redis Sentinel」レッスンは無料ですか?

はい。「高可用性のための Redis Sentinel」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Redis Caching & Messaging (Pub/Sub, Streams)コースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Redis Caching & Messaging (Pub/Sub, Streams)コースには全4レッスンが含まれています。

「高可用性のための Redis Sentinel」で何を学びますか?

Redis Sentinel を設定し、フェイルオーバーを自動管理してサービスの継続的な可用性を確保します。 ブラウザで直接実行するハンズオンコードでRedis Caching & Messaging (Pub/Sub, Streams)を演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Redis Caching & Messaging (Pub/Sub, Streams)を始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのRedis Caching & Messaging (Pub/Sub, Streams)は初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン2/4です。

「高可用性のための Redis Sentinel」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このRedis Caching & Messaging (Pub/Sub, Streams)レッスンでコードを書いて実行できますか?

はい。すべてのRedis Caching & Messaging (Pub/Sub, Streams)レッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. 冗長性確保のための Redis レプリケーション
  2. 高可用性のための Redis Sentinel
  3. シャーディングのための Redis Cluster
  4. クライアント側の接続レジリエンス
← Redis Caching & Messaging (Pub/Sub, Streams)に戻る