docker-compose 一步启动redis集群哨兵模式

一、docker-compose 配置

文中的参数根据需要自行调整

docker-compose.yml

version: '2'
services:
  redis1:
    image: "redis:3.2"
    restart: always
    ports:
      - "23781:23781"
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "4"
    volumes:
      - "/Users/mac/PycharmProjects/aimusic_project/data/redis_data/db1:/data"
      - "./redis1.conf:/etc/redis/redis.conf"
    command: redis-server /etc/redis/redis.conf
    container_name: iguitar_redis1


  redis2:
    image: "redis:3.2"
    restart: always
    ports:
      - "23782:23782"
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "4"
    volumes:
      - "/Users/mac/PycharmProjects/aimusic_project/data/redis_data/db2:/data"
      - "./redis2.conf:/etc/redis/redis.conf"
    command: redis-server /etc/redis/redis.conf
    container_name: iguitar_redis2

  redis3:
    image: "redis:3.2"
    restart: always
    ports:
      - "23783:23783"
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "4"
    volumes:
      - "/Users/mac/PycharmProjects/aimusic_project/data/redis_data/db3:/data"
      - "./redis3.conf:/etc/redis/redis.conf"
    command: redis-server /etc/redis/redis.conf
    container_name: iguitar_redis3
  redis_sentine1:
    image: "redis:3.2"
    restart: always
    ports:
      - "24781:24781"
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "4"
    volumes:
      - "/Users/mac/PycharmProjects/aimusic_project/data/redis_data/sentine_db1:/data"
      - "./redis_sentinel1.conf:/etc/redis/redis.conf"
    command: redis-sentinel /etc/redis/redis.conf
    container_name: redis_sentine1


  redis_sentine2:
    image: "redis:3.2"
    restart: always
    ports:
      - "24782:24782"
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "4"
    volumes:
      - "/Users/mac/PycharmProjects/aimusic_project/data/redis_data/sentine_db2:/data"
      - "./redis_sentinel2.conf:/etc/redis/redis.conf"
    command: redis-sentinel /etc/redis/redis.conf
    container_name: redis_sentine2

  redis_sentine3:
    image: "redis:3.2"
    restart: always
    ports:
      - "24783:24783"
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "4"
    volumes:
      - "/Users/mac/PycharmProjects/aimusic_project/data/redis_data/sentine_db3:/data"
      - "./redis_sentinel3.conf:/etc/redis/redis.conf"
    command: redis-sentinel /etc/redis/redis.conf
    container_name: redis_sentine3

二、redis服务配置

redis1.conf (主)

port 23781
dir "/data"

redis2.conf (从)

port 23782
dir "/data"
slaveof 192.168.1.83 23781

redis3.conf (从)

port 23783
dir "/data"
slaveof 192.168.1.83 23781

三、哨兵配置

redis_sentinel1.conf

port 24781
dir "/data"
sentinel monitor mymaster 192.168.1.83 23781 2
sentinel down-after-milliseconds mymaster 10000
sentinel failover-timeout mymaster 60000

redis_sentinel2.conf

port 24782
dir "/data"
sentinel monitor mymaster 192.168.1.83 23781 2
sentinel down-after-milliseconds mymaster 10000
sentinel failover-timeout mymaster 60000

redis_sentinel3.conf

port 24783
dir "/data"
sentinel monitor mymaster 192.168.1.83 23781 2
sentinel down-after-milliseconds mymaster 10000
sentinel failover-timeout mymaster 60000
更新时间:2019-03-08 14:45:58

本文由 智慧煮粥 创作,如果您觉得本文不错,请随意赞赏
采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
原文链接:http://zz.zzhub.cn/archives/docker-compose一步启动redis集群哨兵模式
最后更新:2019-03-08 14:45:58

评论

Your browser is out of date!

Update your browser to view this website correctly. Update my browser now

×