redis-cluster-dev

Docker-based Redis cluster development environment with multiple topologies (Cluster, Master-Slave, Sentinel) and Redis Insight integration

0
0
0
Shell
public

Redis Cluster Development Environment

Quick setup tool for different Redis cluster topologies using Docker Compose. Perfect for local development with OrbStack, Docker Desktop, or any Docker environment.

⚠️ Security Notice: This setup is designed for LOCAL DEVELOPMENT ONLY. See SECURITY.md for production security considerations.

πŸš€ Quick Start

# Clone or download this project
cd redis-cluster-dev

# Choose your Redis topology:
cd redis-cluster && ./start.sh          # Redis Cluster (sharding)
cd redis-master-slave && ./start.sh     # Master-Slave replication  
cd redis-sentinel && ./start.sh         # Sentinel high availability

πŸ“‹ Available Topologies

1. Redis Cluster (Sharding) - redis-cluster/

  • 3 master nodes + 3 replica nodes
  • Automatic data sharding across nodes
  • Built-in high availability
  • Ports: 7001-7006 (Redis), 17001-17006 (Cluster bus)
  • Redis Insight: http://localhost:5540

2. Redis Master-Slave - redis-master-slave/

  • 1 master node + 2 slave nodes
  • Asynchronous replication
  • Read scaling with slaves
  • Ports: 6379 (master), 6380-6381 (slaves)
  • Redis Insight: http://localhost:5541

3. Redis Sentinel - redis-sentinel/

  • 1 master + 2 slaves + 3 sentinels
  • Automatic failover monitoring
  • High availability without sharding
  • Ports: 6379-6381 (Redis), 26379-26381 (Sentinels)
  • Redis Insight: http://localhost:5542

πŸ”§ Configuration Details

All configurations use Redis 8.2 (latest stable) with optimized settings:

  • AOF persistence enabled
  • Memory policy: allkeys-lru
  • TCP keepalive and backlog optimization
  • Proper networking for container communication
  • Redis Insight pre-configured for each topology

πŸ“Š Redis Insight (Web UI)

Each setup includes Redis Insight - the official Redis GUI for monitoring, managing, and visualizing your Redis data:

  • Redis Cluster: http://localhost:5540

    • Pre-configured cluster topology detection
    • Slot distribution visualization
    • Cross-node key operations
  • Master-Slave: http://localhost:5541

    • Separate connections for master and slaves
    • Replication lag monitoring
    • Read/write operation separation
  • Sentinel: http://localhost:5542

    • Sentinel-aware connections
    • Failover event monitoring
    • Master discovery automation

Redis Insight Features

  • Real-time key browser and editor
  • Command execution with auto-completion
  • Memory usage analysis and optimization
  • Slow query log monitoring
  • Pub/Sub message monitoring
  • Custom command profiling

πŸ›  Usage Examples

Redis Cluster

cd redis-cluster
./start.sh

# Connect to cluster (internal connection via Docker exec)
docker exec redis-cluster-node-1 redis-cli -c -p 6379

# Test sharding (external connections via mapped ports)
redis-cli -c -p 7001 set key1 "value1"
redis-cli -c -p 7002 get key1  # Automatically redirected

Master-Slave

cd redis-master-slave  
./start.sh

# Write to master
docker exec redis-master redis-cli set key1 "value1"

# Read from slave
docker exec redis-slave-1 redis-cli get key1

Sentinel

cd redis-sentinel
./start.sh

# Check sentinel status
docker exec redis-sentinel-1 redis-cli -p 26379 sentinel masters

# Test failover (stop master)
docker stop redis-sentinel-master
docker exec redis-sentinel-1 redis-cli -p 26379 sentinel masters

🧹 Cleanup

# Stop and remove containers
docker-compose down

# Remove volumes (data will be lost)
docker-compose down -v

πŸ“¦ Requirements

  • Docker & Docker Compose
  • OrbStack, Docker Desktop, or compatible Docker environment
  • macOS/Linux/Windows

🎯 Use Cases

  • Development: Test Redis clustering behavior
  • Learning: Understand different Redis topologies
  • Prototyping: Quick Redis setup for applications
  • Testing: Simulate failover and scaling scenarios

πŸ”§ Redis Insight Management

Quick Access

# Interactive setup menu (includes Redis Insight options)
./setup.sh

# Redis Insight configuration helper  
./configure-insight.sh

Manual Configuration

  • All Redis Insight instances come pre-configured with optimal settings
  • Configuration files are located in each topology directory
  • Custom configurations can be created using ./configure-insight.sh

Troubleshooting

# Check running Redis Insight containers
docker ps | grep redis-insight

# Restart Redis Insight for a specific topology
cd redis-cluster && docker-compose restart redis-insight-cluster

# View Redis Insight logs
docker logs redis-insight-cluster

πŸ” Monitoring

Each setup includes connection details and testing commands in the startup output. Use Redis CLI, Redis Insight web interface, or your favorite Redis client to connect and explore.


Redis Version: 8.2 (latest stable)
Compatibility: OrbStack, Docker Desktop, Podman

v0.3.3[beta]