docker-compose1.yml 1.7 KB

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