docker-compose redis集群

redis主从复制

version: '3'
services:
  master:
    image: redis:5
    container_name: redis-master
    restart: always
    command: redis-server --port 6379 --requirepass jd1qaz@WSX  --appendonly yes
    environment:
      - TZ=Asia/Shanghai
    ports:
      - 6379:6379
    volumes:
      - /data/redis/master/data:/data

  slave1:
    image: redis:5
    container_name: redis-slave-1
    restart: always
    command: redis-server --slaveof 192.168.10.184 6379 --port 6379  --requirepass jd1qaz@WSX --masterauth jd1qaz@WSX  --appendonly yes
    environment:
      - TZ=Asia/Shanghai
    ports:
      - 6380:6379
    volumes:
      - /data/redis/slave1/data:/data

参考文档

使用 docker 搭建 Redis 主从同步:http://www.r9it.com/20190826/docker-build-redis-master-slave.html
docker-compose搭建redis集群之主从复制:https://blog.csdn.net/gang_luo/article/details/107555586

posted @ 2021-03-30 10:26  鸣昊  阅读(97)  评论(0编辑  收藏  举报