30 Ocak 2023 Pazartesi

Docker Compose ve Redis Sentinel Mode

Örnek
Şöyle yaparız. Burada bir redis master ve bir redis sentinel var
version: '2'

networks:
  app-tier:
    driver: bridge

services:
  redis:
    image: 'bitnami/redis:latest'
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
    ports:
      - '6379:6379'
    networks:
      - app-tier
  redis-sentinel:
    image: 'bitnami/redis-sentinel:latest'
    environment:
      - REDIS_MASTER_HOST=localhost
      - REDIS_SENTINEL_RESOLVE_HOSTNAMES=yes
    ports:
      - '26379:26379'
    networks:
      - app-tier
Örnek
Şöyle yaparız. REDIS_MASTER_SET ile sentinelin hangi set için çalıştığı belirtilir
version: '3.8'
services:
  redis-master:
    container_name: redis-master
    image: 'bitnami/redis:latest'
    environment:
      - REDIS_REPLICATION_MODE=master
      - REDIS_PASSWORD=redispassword
    ports:
      - "6379:6379"
  redis-slave:
    container_name: slave-redis
    image: 'bitnami/redis:latest'
    environment:
      - REDIS_REPLICATION_MODE=slave
      - REDIS_MASTER_HOST=redis-master
      - REDIS_MASTER_PASSWORD=redispassword
      - REDIS_PASSWORD=redispassword
    ports:
      - "7000:6379"
    depends_on:
      - redis-master
  redis-sentinel-1:
    image: 'bitnami/redis-sentinel:latest'
    container_name: sentinel-1
    environment:
      - REDIS_MASTER_SET=mymaster
      - REDIS_MASTER_HOST=127.0.0.1
      - REDIS_MASTER_PASSWORD=redispassword
      - REDIS_SENTINEL_DOWN_AFTER_MILLISECONDS=10000
    depends_on:
      - redis-master
      - redis-slave
    ports: 
       - "26379:26379"
  redis-sentinel-2:
    image: 'bitnami/redis-sentinel:latest'
    container_name: sentinel-2
    environment:
      - REDIS_MASTER_SET=mymaster
      - REDIS_MASTER_HOST=127.0.0.1
      - REDIS_MASTER_PASSWORD=redispassword
      - REDIS_SENTINEL_DOWN_AFTER_MILLISECONDS=10000
    depends_on:
      - redis-master
      - redis-slave
    ports: 
      - "26380:26379"
  redis-sentinel-3:
    image: 'bitnami/redis-sentinel:latest'
    container_name: sentinel-3
    environment:
      - REDIS_MASTER_SET=mymaster
      - REDIS_MASTER_HOST=127.0.0.1
      - REDIS_MASTER_PASSWORD=redispassword
      - REDIS_SENTINEL_DOWN_AFTER_MILLISECONDS=10000
    depends_on:
      - redis-master
      - redis-slave
    ports: 
      - "26381:26379"


Hiç yorum yok:

Yorum Gönder