| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- services:
- redis-slave-1:
- image: registry.cn-chengdu.aliyuncs.com/reghao/redis:6.0.16-bullseye
- container_name: redis-slave-1
- restart: always
- ports:
- - "6379:6379"
- volumes:
- - /etc/localtime:/etc/localtime:ro
- - /opt/docker/redis/redis.conf:/etc/redis/redis.conf
- - /opt/docker/redis/data:/data
- # 🚨 容器日志限制
- logging:
- driver: "json-file"
- options:
- max-size: "50m"
- max-file: "3"
- # 🚨 从节点资源限制(与主节点保持完全一致,以便故障转移后能完美顶上)
- deploy:
- resources:
- limits:
- cpus: '1.0'
- memory: 2G
- reservations:
- cpus: '0.5'
- memory: 512M
- # 同样建议开启从节点的 AOF
- command: redis-server /etc/redis/redis.conf --replicaof 192.168.0.211 6379 --appendonly yes
- healthcheck:
- test: [ "CMD", "redis-cli", "ping" ]
- interval: 5s
- timeout: 3s
- retries: 5
- start_period: 10s
- sentinel-2:
- image: registry.cn-chengdu.aliyuncs.com/reghao/redis:6.0.16-bullseye
- container_name: sentinel-2
- restart: always
- ports:
- - "26379:26379"
- command: redis-sentinel /etc/redis/sentinel.conf
- volumes:
- - /etc/localtime:/etc/localtime:ro
- - /opt/docker/redis/sentinel/sentinel.conf:/etc/redis/sentinel.conf
- logging:
- driver: "json-file"
- options:
- max-size: "20m"
- max-file: "3"
- deploy:
- resources:
- limits:
- cpus: '0.5'
- memory: 512M
- reservations:
- cpus: '0.2'
- memory: 256M
- healthcheck:
- test: [ "CMD", "redis-cli", "-p", "26379", "ping" ]
- interval: 5s
- timeout: 3s
- retries: 5
|