| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- services:
- mysql80-1:
- image: registry.cn-chengdu.aliyuncs.com/reghao/mysql:8.0.36
- container_name: mysql80-1
- hostname: node211
- restart: always
- network_mode: host
- environment:
- MYSQL_ROOT_PASSWORD: "Root_123456"
- volumes:
- - /etc/localtime:/etc/localtime:ro
- - /opt/docker/mysql/conf/my.cnf:/etc/mysql/conf.d/my.cnf
- - /opt/docker/mysql/data:/var/lib/mysql
- - /opt/docker/mysql/log:/var/log/mysql
- # 🚨 1. 容器日志限制:防止标准输出无节制增长
- logging:
- driver: "json-file"
- options:
- max-size: "100m" # 单个日志文件最大 100M
- max-file: "3" # 最多保留 3 个归档文件
- # 🚨 2. 资源限制与预留(生产环境建议:MySQL 单独占领一台机器,这里限制 2核4G 开销)
- deploy:
- resources:
- limits:
- cpus: '2.0'
- memory: 4G
- reservations:
- cpus: '1.0'
- memory: 2G
- healthcheck:
- test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-u", "root", "-p$${MYSQL_ROOT_PASSWORD}"]
- interval: 5s
- timeout: 5s
- retries: 10
- proxysql:
- image: registry.cn-chengdu.aliyuncs.com/reghao/proxysql_proxysql:8.0.36
- container_name: proxysql
- restart: always
- network_mode: host
- volumes:
- - /etc/localtime:/etc/localtime:ro
- # ProxySQL 日志限制
- logging:
- driver: "json-file"
- options:
- max-size: "50m"
- max-file: "3"
- # ProxySQL 资源限制(作为转发层,日常消耗极低)
- deploy:
- resources:
- limits:
- cpus: '1.0'
- memory: 1G
- reservations:
- cpus: '0.5'
- memory: 512M
- healthcheck:
- test: [ "CMD", "mysql", "-uadmin", "-padmin", "-h127.0.0.1", "-P6032", "-e", "SELECT 1" ]
- interval: 10s
- timeout: 5s
- retries: 3
- start_period: 10s
|