Skip to content

Instantly share code, notes, and snippets.

@limboinf
Created March 19, 2025 08:38
Show Gist options
  • Save limboinf/faeb8b0100a92089fa1eb97247cd8888 to your computer and use it in GitHub Desktop.
Save limboinf/faeb8b0100a92089fa1eb97247cd8888 to your computer and use it in GitHub Desktop.
redis sentinel docker compose
version: '3'
services:
redis-master:
image: bitnami/redis:latest
ports:
- "6379:6379"
environment:
- REDIS_REPLICATION_MODE=master
- ALLOW_EMPTY_PASSWORD=yes
- REDIS_MASTER_HOST=127.0.0.1 # 使用本地回环地址
networks:
- redis-net
# 添加主机名
hostname: redis-master
# 添加额外的主机配置
extra_hosts:
- "host.docker.internal:host-gateway"
redis-replica:
image: bitnami/redis:latest
ports:
- "6380:6379"
depends_on:
- redis-master
environment:
- REDIS_REPLICATION_MODE=slave
- REDIS_MASTER_HOST=redis-master
- ALLOW_EMPTY_PASSWORD=yes
- REDIS_MASTER_HOST=127.0.0.1 # 使用本地回环地址
networks:
- redis-net
redis-sentinel-1:
image: bitnami/redis-sentinel:latest
ports:
- "26379:26379"
depends_on:
- redis-master
- redis-replica
environment:
- REDIS_SENTINEL_DOWN_AFTER_MILLISECONDS=5000
- REDIS_MASTER_HOST=redis-master
- REDIS_MASTER_PORT_NUMBER=6379
- REDIS_MASTER_SET=mymaster
- REDIS_SENTINEL_QUORUM=2
- ALLOW_EMPTY_PASSWORD=yes
networks:
- redis-net
redis-sentinel-2:
image: bitnami/redis-sentinel:latest
ports:
- "26380:26379"
depends_on:
- redis-master
- redis-replica
environment:
- REDIS_SENTINEL_DOWN_AFTER_MILLISECONDS=5000
- REDIS_MASTER_HOST=redis-master
- REDIS_MASTER_PORT_NUMBER=6379
- REDIS_MASTER_SET=mymaster
- REDIS_SENTINEL_QUORUM=2
- ALLOW_EMPTY_PASSWORD=yes
networks:
- redis-net
redis-sentinel-3:
image: bitnami/redis-sentinel:latest
ports:
- "26381:26379"
depends_on:
- redis-master
- redis-replica
environment:
- REDIS_SENTINEL_DOWN_AFTER_MILLISECONDS=5000
- REDIS_MASTER_HOST=redis-master
- REDIS_MASTER_PORT_NUMBER=6379
- REDIS_MASTER_SET=mymaster
- REDIS_SENTINEL_QUORUM=2
- ALLOW_EMPTY_PASSWORD=yes
networks:
- redis-net
networks:
redis-net:
driver: bridge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment