| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- services:
- redis-master:
- image: registry.cn-chengdu.aliyuncs.com/reghao/redis:6.0.16-bullseye
- container_name: redis-master
- restart: always
- network_mode: host
- # 开启 AOF 持久化(生产环境建议开启)
- command: redis-server /etc/redis/redis.conf --appendonly yes
- 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
- healthcheck:
- test: [ "CMD", "redis-cli", "ping" ]
- interval: 5s
- timeout: 3s
- retries: 5
- start_period: 10s
- sentinel-1:
- image: registry.cn-chengdu.aliyuncs.com/reghao/redis:6.0.16-bullseye
- container_name: sentinel-1
- restart: always
- network_mode: host
- 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
|