Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle custom my.cnf file. #4

Open
bmschmidt opened this issue Oct 10, 2020 · 4 comments
Open

Bundle custom my.cnf file. #4

bmschmidt opened this issue Oct 10, 2020 · 4 comments
Assignees

Comments

@bmschmidt
Copy link
Collaborator

bmschmidt commented Oct 10, 2020

I generally change to put at least the following variables into the file read by maria/mysql on startup.

A couple of these are custom for my computer, but dividing datadir and tmpdir can occasionally be useful.

Most of these tune build performance. It's actually possible that they should be switched around when going into production mode.

They also assume a fairly large amount of RAM, so it's possible that for instances of less than 1 million documents--or bookworms willing to take the performance hit of not using memory tables--the approach here needs to be a bit different.

[mysqld]
tmp_table_size = 1024M
datadir = /drobo/mysql
tmpdir = /drobo/tmp
read_rnd_buffer_size = 8M
read_buffer_size = 8M
max_heap_table_size = 2048M # RAM
character_set_server = utf8
query_cache_size = 32M
bulk_insert_buffer_size = 512M
myisam_max_sort_file_size = 5500G
sort_buffer_size = 8M
query_cache_limit = 8M
max_allowed_packet = 512M
key_buffer_size = 2500M
query_cache_type = 1
### = = = THIS FILE SHOULD GENERALLY BE PLACED AT /etc/mysql/my.cnf = = = ###
myisam_sort_buffer_size = 5512M
@senderle
Copy link
Owner

So in the context of Docker, this raises some questions. For my purposes I've never needed anything more than the few config environment variables that the official MySQL image looks for. I don't think there are environment variables for these, so this might mean doing a custom image build? But I am not sure. Something we will have to look into. I love the convenience of using the official image, but it's not a big deal if we can't.

@bmschmidt
Copy link
Collaborator Author

Looks easy. Both mariadb and mysql's standard images seem to have something like this in them:

mariadb. If you want to use a customized MySQL configuration, you can create your alternative configuration file in a directory on the host machine and then mount that directory location as /etc/mysql/conf.d inside the mariadb container.

mysql The default configuration for MySQL can be found in /etc/mysql/my.cnf, which may !includedir additional directories such as /etc/mysql/conf.d or /etc/mysql/mysql.conf.d. Please inspect the relevant files and directories within the mysql image itself for more details.

If /my/custom/config-file.cnf is the path and name of your custom configuration file, you can start your mysql container like this (note that only the directory path of the custom config file is used in this command):

$ docker run --name some-mysql -v /my/custom:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag
This will start a new container some-mysql where the MySQL instance uses the combined startup settings from /etc/mysql/my.cnf and /etc/mysql/conf.d/config-file.cnf, with settings from the latter taking precedence.

@senderle
Copy link
Owner

Ah, of course, we can just mount it.

Digression: Now I'm wondering why we can't do the same thing with traefik, avoiding another custom build and further simplifying the project. I'm working with a lot of patterns from cookiecutter-django... they generally have very good reasons for these kinds of decisions, but I'm not sure about the why in that case.

@bmschmidt bmschmidt self-assigned this Oct 13, 2020
@bmschmidt bmschmidt changed the title Custom my.cnf file. Bundle custom my.cnf file. Oct 13, 2020
@bmschmidt
Copy link
Collaborator Author

Exists--just need to mount compose/mysql/conf.d in. Might be worth bundling large and small files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants