docker-compose2.yml 1.7 KB

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