1.找到Perconna Server的GIthub的Docker Compose文件,具体地址如下
https://github.com/percona/percona-docker/blob/master/percona-server.57/docker-compose.yml
version: '2'
services:
percona-server:
image: percona/percona-server:5.7
environment:
MYSQL_ROOT_PASSWORD: secret
ports:
- "50002:3306"
volumes:
# create volumes for use
- /opt/percona-server/mysql:/var/lib/mysql
# bind mount my local my.cnf
- /opt/percona-server/my.cnf:/etc/my.cnf.d/my.cnf
# uncomment sections below if you want to enable PMM
# pmm-server:
# image: percona/pmm-server:latest
# ports:
# - "443:443"
# environment:
# - SERVER_USER=pmm
# - SERVER_PASSWORD=pmm
# pmm-client-ps:
# image: perconalab/pmm-client:latest
# environment:
# - PMM_SERVER=pmm-server:443
# - PMM_USER=pmm
# - PMM_PASSWORD=pmm
# - DB_TYPE=mysql
# - DB_HOST=percona-server
# - DB_PORT=3306
# - DB_USER=root
# - DB_PASSWORD=secret
2.为什么将data目录和cnf目录映射到主机?
2.1.把data目录映射出来便于管理数据库文件,了解数据库文件,/opt/percona-server/mysql目录要设置777权限
2.2其次mysql5.7需要做一些配置优化
3.my.cnf配置如下,其他优化请根据服务器,自己调优:
[mysqld]
lower_case_table_names=1
sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION