Back to Redis Hub
Module 02: High Availability

Redis Sentinel: HA Quickstart

A streamlined 4-step guide to automated failover and 3-node HA cluster setup.

SECTION 1: Introduction

Redis Sentinel provides **High Availability (HA)** for Redis. It monitors your master and replicas, automatically promoting a replica to master if it detects a failure.

Monitoring

Constant heartbeat checks on all nodes.

Auto-Failover

Elects new master via quorum without downtime.

SECTION 2: Architecture

Redis Standalone Architecture

**Quorum**: 2 Sentinels must agree for a failover to trigger.

SECTION 3: Installation & 3-Node Setup

1. Installation (Download & Compile)

# Run on all nodes (AL2023 ARM64 example)
sudo dnf update -y && sudo dnf install -y jemalloc-devel openssl-devel systemd-devel wget
wget https://download.redis.io/releases/redis-8.0.0.tar.gz
tar -xzf redis-8.0.0.tar.gz && cd redis-8.0.0
make BUILD_TLS=yes -j$(nproc) && sudo make install

2. Node Configuration (redis.conf)

# MASTER CONFIG (Node 1)
bind 0.0.0.0
port 6379
requirepass "ARCH_PASS"
masterauth "ARCH_PASS"
appendonly yes
supervised systemd
# REPLICA CONFIG (Node 2 & 3)
bind 0.0.0.0
port 6379
replicaof 10.0.1.10 6379
requirepass "ARCH_PASS"
masterauth "ARCH_PASS"
replica-read-only yes
supervised systemd

3. Sentinel Configuration (sentinel.conf)

# ALL NODES
port 26379
sentinel monitor mymaster 10.0.1.10 6379 2
sentinel auth-pass mymaster ARCH_PASS
sentinel down-after-milliseconds mymaster 5000
sentinel failover-timeout mymaster 60000

4. Systemd Service (/etc/systemd/system/redis.service)

[Unit]
Description=Redis HA Service
After=network.target

[Service]
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
Restart=always
User=redis

[Install]
WantedBy=multi-user.target

5. Deployment Commands

  • Enable Services: `sudo systemctl enable --now redis`
  • Start Sentinel: `sudo redis-sentinel /etc/redis/sentinel.conf &`
  • Verify: `redis-cli -p 26379 sentinel masters`

SECTION 4: Failover Simulation

Simulate Master Crash

Hold the master in a non-responsive sleep state for 60 seconds to force an election.

redis-cli -h 10.0.1.10 -a ARCH_PASS DEBUG sleep 60

Election Timeline

1

**0s-5s**: Master down. S1 detects SDOWN.

2

**5s-7s**: Sentinels gossip. Quorum reached. **+ODOWN** logic triggers.

3

**10s**: Replica promoted. **+switch-master** broadcasted.