docker-compose3.yml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. 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. command: redis-server /etc/redis/redis.conf --replicaof 192.168.0.211 6379 --appendonly yes
  28. healthcheck:
  29. test: [ "CMD", "redis-cli", "ping" ]
  30. interval: 5s
  31. timeout: 3s
  32. retries: 5
  33. start_period: 10s
  34. sentinel-3:
  35. image: registry.cn-chengdu.aliyuncs.com/reghao/redis:6.0.16-bullseye
  36. container_name: sentinel-3
  37. restart: always
  38. ports:
  39. - "26379:26379"
  40. command: redis-sentinel /etc/redis/sentinel.conf
  41. volumes:
  42. - /etc/localtime:/etc/localtime:ro
  43. - /opt/docker/redis/sentinel/sentinel.conf:/etc/redis/sentinel.conf
  44. logging:
  45. driver: "json-file"
  46. options:
  47. max-size: "20m"
  48. max-file: "3"
  49. deploy:
  50. resources:
  51. limits:
  52. cpus: '0.5'
  53. memory: 512M
  54. reservations:
  55. cpus: '0.2'
  56. memory: 256M
  57. healthcheck:
  58. test: [ "CMD", "redis-cli", "-p", "26379", "ping" ]
  59. interval: 5s
  60. timeout: 3s
  61. retries: 5