mirror of
https://gitee.com/kennylee/docker.git
synced 2024-12-01 19:38:30 +08:00
优化mysql的镜像,默认配置和自定义配置分离,并且修改说明文档
This commit is contained in:
parent
7bedc4150f
commit
efddbc08ba
@ -6,16 +6,17 @@
|
||||
|
||||
修改:
|
||||
|
||||
1. 修改默认mysql默认编码为utf-8
|
||||
2. 可自行修改my.cnf进行构建
|
||||
1. 修改官网的my.cnf文件,配置编码为utf-8
|
||||
2. 增加/etc/mysql/mysql-my.conf.d/的配置目录,方便启动容器的时候映射额外mysql的配置目录。
|
||||
3. 去掉默认的 VOLUME /var/lib/mysql 方便备份。
|
||||
|
||||
### 配置
|
||||
### 自定义配置
|
||||
|
||||
* 最大连接数:可参考下docker-compose.yml,启动容器的时候传入`--max_connections=300`参数配置即可。
|
||||
1. 在宿主机上映射镜像内部的`/etc/mysql/mysql-my.conf.d/`目录,然后创建cnf文件,再把自定义的配置填写在里面。
|
||||
2. 启动容器的时候,通过cmd的方法传入配置。
例如,最大连接数(可参考下docker-compose.yml)启动容器的时候传入`--max_connections=300`参数配置即可。
|
||||
|
||||
|
||||
### 阿里云构建的镜像
|
||||
### 镜像下载
|
||||
|
||||
```
|
||||
docker pull registry.cn-hangzhou.aliyuncs.com/kennylee/mysql
|
||||
|
19
mysql/conf/mysqld.cnf
Normal file
19
mysql/conf/mysqld.cnf
Normal file
@ -0,0 +1,19 @@
|
||||
[mysqld]
|
||||
# 开启binlog
|
||||
server-id = 1
|
||||
log-bin = /var/log/mysql/mysql-bin.log
|
||||
binlog_format = MIXED
|
||||
# 自动删除7天之前的binlog
|
||||
expire_logs_days = 7
|
||||
|
||||
# 开启慢查询日志配置
|
||||
slow_query_log = 1
|
||||
slow_query_log_file = /var/log/mysql/mysql-slow-queries.log
|
||||
# 超过定义为慢查询
|
||||
long_query_time = 4
|
||||
|
||||
# 日志输出方式
|
||||
#log_output = FILE,TABLE
|
||||
#
|
||||
# 未使用索引的查询也被记录到慢查询日志中
|
||||
#log_queries_not_using_indexes = 1
|
@ -12,7 +12,8 @@ services:
|
||||
- MYSQL_ROOT_PASSWORD=111111
|
||||
volumes:
|
||||
- ./data/standalong:/var/lib/mysql/:z
|
||||
#- ./data/standalong-logs:/var/log/mysql/:z
|
||||
- ./conf/:/etc/mysql/mysql-my.conf.d/:z
|
||||
- ./data/standalong-logs:/var/log/mysql/:z
|
||||
command: ["--max_connections=300"]
|
||||
logging:
|
||||
driver: 'json-file'
|
||||
|
21
mysql/my.cnf
21
mysql/my.cnf
@ -61,25 +61,10 @@ sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
|
||||
# Disabling symbolic-links is recommended to prevent assorted security risks
|
||||
symbolic-links=0
|
||||
|
||||
# 开启binlog
|
||||
server-id = 1
|
||||
log-bin = /var/log/mysql/mysql-bin.log
|
||||
binlog_format = MIXED
|
||||
# 自动删除7天之前的binlog
|
||||
expire_logs_days = 7
|
||||
|
||||
# 慢查询配置
|
||||
slow_query_log = 1
|
||||
slow_query_log_file = /var/log/mysql/mysql-slow-queries.log
|
||||
# 超过定义为慢查询
|
||||
long_query_time = 4
|
||||
|
||||
# 日志输出方式
|
||||
# log_output = FILE,TABLE
|
||||
# 未使用索引的查询也被记录到慢查询日志中
|
||||
log_queries_not_using_indexes = 1
|
||||
|
||||
# * IMPORTANT: Additional settings that can override those from this file!
|
||||
# The files must end with '.cnf', otherwise they'll be ignored.
|
||||
#
|
||||
!includedir /etc/mysql/conf.d/
|
||||
|
||||
# 自定义扩展mysql的配置可以写在这里,优先级最高
|
||||
!includedir /etc/mysql/mysql-my.conf.d/
|
||||
|
Loading…
Reference in New Issue
Block a user