docker-compose3.yml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. services:
  2. redis-slave-2:
  3. image: registry.cn-chengdu.aliyuncs.com/reghao/redis:6.0.16-bullseye
  4. container_name: redis-slave-2
  5. restart: always
  6. network_mode: host
  7. volumes:
  8. - /etc/localtime:/etc/localtime:ro
  9. - /opt/docker/redis/redis.conf:/etc/redis/redis.conf
  10. - /opt/docker/redis/data:/data
  11. # 🚨 容器日志限制
  12. logging:
  13. driver: "json-file"
  14. options:
  15. max-size: "50m"
  16. max-file: "3"
  17. # 🚨 从节点资源限制(与主节点保持完全一致,以便故障转移后能完美顶上)
  18. deploy:
  19. resources:
  20. limits:
  21. cpus: '1.0'
  22. memory: 2G
  23. reservations:
  24. cpus: '0.5'
  25. memory: 512M
  26. command: redis-server /etc/redis/redis.conf --replicaof 192.168.0.211 6379 --appendonly yes
  27. healthcheck:
  28. test: [ "CMD", "redis-cli", "ping" ]
  29. interval: 5s
  30. timeout: 3s
  31. retries: 5
  32. start_period: 10s
  33. sentinel-3:
  34. image: registry.cn-chengdu.aliyuncs.com/reghao/redis:6.0.16-bullseye
  35. container_name: sentinel-3
  36. restart: always
  37. network_mode: host
  38. command: redis-sentinel /etc/redis/sentinel.conf
  39. volumes:
  40. - /etc/localtime:/etc/localtime:ro
  41. - /opt/docker/redis/sentinel/sentinel.conf:/etc/redis/sentinel.conf
  42. logging:
  43. driver: "json-file"
  44. options:
  45. max-size: "20m"
  46. max-file: "3"
  47. deploy:
  48. resources:
  49. limits:
  50. cpus: '0.5'
  51. memory: 512M
  52. reservations:
  53. cpus: '0.2'
  54. memory: 256M
  55. healthcheck:
  56. test: [ "CMD", "redis-cli", "-p", "26379", "ping" ]
  57. interval: 5s
  58. timeout: 3s
  59. retries: 5