docker-compose2.yml 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. 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. # 同样建议开启从节点的 AOF
  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-2:
  35. image: registry.cn-chengdu.aliyuncs.com/reghao/redis:6.0.16-bullseye
  36. container_name: sentinel-2
  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