From 5c5b0e52f0dacc0d80f7998759e288317626a5ba Mon Sep 17 00:00:00 2001 From: Kirtan Gajjar Date: Tue, 3 Nov 2020 16:46:18 +0530 Subject: [PATCH 1/3] Add custom pinned mariadb cnf file --- mariadb/Dockerfile | 3 +- mariadb/my.cnf | 240 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 242 insertions(+), 1 deletion(-) create mode 100644 mariadb/my.cnf diff --git a/mariadb/Dockerfile b/mariadb/Dockerfile index db82f84..224d922 100644 --- a/mariadb/Dockerfile +++ b/mariadb/Dockerfile @@ -3,4 +3,5 @@ LABEL org.label-schema.schema-version="1.0.0-rc1" LABEL org.label-schema.vendor="EasyEngine" LABEL org.label-schema.name="db" -COPY ee.cnf /etc/mysql/conf.d/ee.cnf \ No newline at end of file +COPY ee.cnf /etc/mysql/conf.d/ee.cnf +COPY my.cnf /etc/mysql/ \ No newline at end of file diff --git a/mariadb/my.cnf b/mariadb/my.cnf new file mode 100644 index 0000000..04b5e20 --- /dev/null +++ b/mariadb/my.cnf @@ -0,0 +1,240 @@ +# The MariaDB configuration file +# +# The MariaDB/MySQL tools read configuration files in the following order: +# 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults, +# 2. "/etc/mysql/conf.d/*.cnf" to set global options. +# 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options. +# 4. "~/.my.cnf" to set user-specific options. +# +# If the same option is defined multiple times, the last one will apply. +# +# One can use all long options that the program supports. +# Run program with --help to get a list of available options and with +# --print-defaults to see which it would actually understand and use. + +# +# This group is read both by the client and the server +# use it for options that affect everything +# +[client-server] + +socket = /run/mysqld/mysqld.sock +#port = 3306 + +# +# This group is read by the client library +# Use it for options that affect all clients, but not the server +# + +[client] +# Default is Latin1, if you need UTF-8 set this (also in server section) +# default-character-set = utf8mb4 + +# Example of client certificate usage +# ssl-cert=/etc/mysql/client-cert.pem +# ssl-key=/etc/mysql/client-key.pem +# +# Allow only TLS encrypted connections +# ssl-verify-server-cert=on + +# This group is *never* read by mysql client library, though this +# /etc/mysql/mariadb.cnf.d/client.cnf file is not read by Oracle MySQL +# client anyway. +# If you use the same .cnf file for MySQL and MariaDB, +# use it for MariaDB-only client options +[client-mariadb] + +# +# These groups are read by MariaDB command-line tools +# Use it for options that affect only one utility +# + +[mysql] + +[mysql_upgrade] + +[mysqladmin] + +[mysqlbinlog] + +[mysqlcheck] + +[mysqldump] + +[mysqlimport] + +[mysqlshow] + +[mysqlslap] + +# NOTE: THIS FILE IS READ ONLY BY THE TRADITIONAL SYSV INIT SCRIPT, NOT SYSTEMD. +# MARIADB SYSTEMD DOES _NOT_ UTILIZE MYSQLD_SAFE NOR READ THIS FILE. +# +# For similar behavior, systemd users should create the following file: +# /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf +# +# To achieve the same result as the default 50-mysqld_safe.cnf, please create +# /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf +# with the following contents: +# +# [Service] +# User=mysql +# StandardOutput=syslog +# StandardError=syslog +# SyslogFacility=daemon +# SyslogLevel=err +# SyslogIdentifier=mysqld +# +# For more information, please read https://mariadb.com/kb/en/mariadb/systemd/ + +[mysqld_safe] +# This will be passed to all mysql clients +# It has been reported that passwords should be enclosed with ticks/quotes +# especially if they contain "#" chars... + +nice = 0 +skip_log_error +syslog + +# +# These groups are read by MariaDB server. +# Use it for options that only the server (but not clients) should see + +# this is read by the standalone daemon and embedded servers +[server] + +# this is only for the mysqld standalone daemon +[mysqld] + +# +# * Basic Settings +# + +#user = mysql +pid-file = /run/mysqld/mysqld.pid +basedir = /usr +datadir = /var/lib/mysql +tmpdir = /tmp +lc-messages-dir = /usr/share/mysql +lc-messages = en_US +skip-external-locking + +# Broken reverse DNS slows down connections considerably and name resolve is +# safe to skip if there are no "host by domain name" access grants +#skip-name-resolve + +# Instead of skip-networking the default is now to listen only on +# localhost which is more compatible and is not less secure. +#bind-address = 127.0.0.1 + +# +# * Fine Tuning +# + +#key_buffer_size = 128M +#max_allowed_packet = 1G +#thread_stack = 192K +#thread_cache_size = 8 +# This replaces the startup script and checks MyISAM tables if needed +# the first time they are touched +#myisam_recover_options = BACKUP +#max_connections = 100 +#table_cache = 64 + +# +# * Logging and Replication +# + +# Both location gets rotated by the cronjob. +# Be aware that this log type is a performance killer. +# Recommend only changing this at runtime for short testing periods if needed! +#general_log_file = /var/log/mysql/mysql.log +#general_log = 1 + +# When running under systemd, error logging goes via stdout/stderr to journald +# and when running legacy init error logging goes to syslog due to +# /etc/mysql/conf.d/mariadb.conf.d/50-mysqld_safe.cnf +# Enable this if you want to have error logging into a separate file +#log_error = /var/log/mysql/error.log +# Enable the slow query log to see queries with especially long duration +#slow_query_log_file = /var/log/mysql/mariadb-slow.log +#long_query_time = 10 +#log_slow_verbosity = query_plan,explain +#log-queries-not-using-indexes +#min_examined_row_limit = 1000 + +# The following can be used as easy to replay backup logs or for replication. +# note: if you are setting up a replication slave, see README.Debian about +# other settings you may need to change. +#server-id = 1 +#log_bin = /var/log/mysql/mysql-bin.log +expire_logs_days = 10 +#max_binlog_size = 100M + +# +# * SSL/TLS +# + +# For documentation, please read +# https://mariadb.com/kb/en/securing-connections-for-client-and-server/ +#ssl-ca = /etc/mysql/cacert.pem +#ssl-cert = /etc/mysql/server-cert.pem +#ssl-key = /etc/mysql/server-key.pem + +# +# * Character sets +# + +# MySQL/MariaDB default is Latin1, but in Debian we rather default to the full +# utf8 4-byte character set. See also client.cnf +character-set-server = utf8mb4 +collation-server = utf8mb4_general_ci + +# +# * InnoDB +# + +# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. +# Read the manual for more InnoDB related options. There are many! +# Most important is to give InnoDB 80 % of the system RAM for buffer use: +# https://mariadb.com/kb/en/innodb-system-variables/#innodb_buffer_pool_size +#innodb_buffer_pool_size = 8G + +# this is only for embedded server +[embedded] + +# This group is only read by MariaDB servers, not by MySQL. +# If you use the same .cnf file for MySQL and MariaDB, +# you can put MariaDB-only options here +[mariadb] + +# This group is only read by MariaDB-10.5 servers. +# If you use the same .cnf file for MariaDB of different versions, +# use this group for options that older servers don't understand +[mariadb-10.5] + +# +# * Galera-related settings +# +# See the examples of server wsrep.cnf files in /usr/share/mysql + +[galera] +# Mandatory settings +#wsrep_on=ON +#wsrep_provider= +#wsrep_cluster_address= +#binlog_format=row +#default_storage_engine=InnoDB +#innodb_autoinc_lock_mode=2 + +# Allow server to accept connections on all interfaces. +#bind-address=0.0.0.0 + +# Optional settings +#wsrep_slave_threads=1 +#innodb_flush_log_at_trx_commit=0 + + +# Import all .cnf files from configuration directory +!includedir /etc/mysql/conf.d/ +!includedir /etc/mysql/mariadb.conf.d/ From e4fb00c81998f277197d76476e17dcebbcb2849c Mon Sep 17 00:00:00 2001 From: Kirtan Gajjar Date: Tue, 3 Nov 2020 16:47:31 +0530 Subject: [PATCH 2/3] Replace empty config file with EE config file --- mariadb/my.cnf | 110 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 79 insertions(+), 31 deletions(-) diff --git a/mariadb/my.cnf b/mariadb/my.cnf index 04b5e20..4b94d2f 100644 --- a/mariadb/my.cnf +++ b/mariadb/my.cnf @@ -1,7 +1,7 @@ # The MariaDB configuration file # # The MariaDB/MySQL tools read configuration files in the following order: -# 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults, +# 1. "/etc/mysql/my.cnf" (this file) to set global defaults, # 2. "/etc/mysql/conf.d/*.cnf" to set global options. # 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options. # 4. "~/.my.cnf" to set user-specific options. @@ -19,7 +19,7 @@ [client-server] socket = /run/mysqld/mysqld.sock -#port = 3306 +port = 3306 # # This group is read by the client library @@ -28,7 +28,7 @@ socket = /run/mysqld/mysqld.sock [client] # Default is Latin1, if you need UTF-8 set this (also in server section) -# default-character-set = utf8mb4 +default-character-set = utf8mb4 # Example of client certificate usage # ssl-cert=/etc/mysql/client-cert.pem @@ -60,6 +60,9 @@ socket = /run/mysqld/mysqld.sock [mysqlcheck] [mysqldump] +quick +quote-names +max_allowed_packet = 16M [mysqlimport] @@ -91,8 +94,8 @@ socket = /run/mysqld/mysqld.sock # This will be passed to all mysql clients # It has been reported that passwords should be enclosed with ticks/quotes # especially if they contain "#" chars... - -nice = 0 +socket = /var/run/mysqld/mysqld.sock +nice = 0 skip_log_error syslog @@ -110,8 +113,10 @@ syslog # * Basic Settings # -#user = mysql +#user = mysql pid-file = /run/mysqld/mysqld.pid +socket = /var/run/mysqld/mysqld.sock +port = 3306 basedir = /usr datadir = /var/lib/mysql tmpdir = /tmp @@ -123,23 +128,43 @@ skip-external-locking # safe to skip if there are no "host by domain name" access grants #skip-name-resolve +# # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. -#bind-address = 127.0.0.1 - +#bind-address = 127.0.0.1 # # * Fine Tuning # - -#key_buffer_size = 128M -#max_allowed_packet = 1G -#thread_stack = 192K -#thread_cache_size = 8 +max_connections = 100 +connect_timeout = 5 +wait_timeout = 600 +max_allowed_packet = 16M +thread_cache_size = 128 +sort_buffer_size = 4M +bulk_insert_buffer_size = 16M +tmp_table_size = 32M +max_heap_table_size = 32M +# +# * MyISAM +# # This replaces the startup script and checks MyISAM tables if needed -# the first time they are touched -#myisam_recover_options = BACKUP -#max_connections = 100 -#table_cache = 64 +# the first time they are touched. On error, make copy and try a repair. +myisam_recover_options = BACKUP +key_buffer_size = 128M +#open-files-limit = 2000 +table_open_cache = 400 +myisam_sort_buffer_size = 512M +concurrent_insert = 2 +read_buffer_size = 2M +read_rnd_buffer_size = 1M +# +# * Query Cache Configuration +# +# Cache only tiny result sets, so we can fit more in the query cache. +query_cache_limit = 128K +query_cache_size = 64M +# for more write intensive setups, set to DEMAND or OFF +#query_cache_type = DEMAND # # * Logging and Replication @@ -155,12 +180,17 @@ skip-external-locking # and when running legacy init error logging goes to syslog due to # /etc/mysql/conf.d/mariadb.conf.d/50-mysqld_safe.cnf # Enable this if you want to have error logging into a separate file +# we do want to know about network errors and such +#log_warnings = 2 #log_error = /var/log/mysql/error.log # Enable the slow query log to see queries with especially long duration -#slow_query_log_file = /var/log/mysql/mariadb-slow.log -#long_query_time = 10 +#slow_query_log[={0|1}] +slow_query_log_file = /var/log/mysql/mariadb-slow.log +long_query_time = 10 +#log_slow_rate_limit = 1000 #log_slow_verbosity = query_plan,explain #log-queries-not-using-indexes +#log_slow_admin_statements #min_examined_row_limit = 1000 # The following can be used as easy to replay backup logs or for replication. @@ -171,6 +201,30 @@ skip-external-locking expire_logs_days = 10 #max_binlog_size = 100M +# +# If applications support it, this stricter sql_mode prevents some +# mistakes like inserting invalid dates etc. +#sql_mode = NO_ENGINE_SUBSTITUTION,TRADITIONAL + +# +# * InnoDB +# + +# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. +# Read the manual for more InnoDB related options. There are many! +# Most important is to give InnoDB 80 % of the system RAM for buffer use: +# https://mariadb.com/kb/en/innodb-system-variables/#innodb_buffer_pool_size + +default_storage_engine = InnoDB +# you can't just change log file size, requires special procedure +#innodb_log_file_size = 50M +innodb_buffer_pool_size = 256M +innodb_log_buffer_size = 8M +innodb_file_per_table = 1 +innodb_open_files = 400 +innodb_io_capacity = 400 +innodb_flush_method = O_DIRECT + # # * SSL/TLS # @@ -190,16 +244,6 @@ expire_logs_days = 10 character-set-server = utf8mb4 collation-server = utf8mb4_general_ci -# -# * InnoDB -# - -# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. -# Read the manual for more InnoDB related options. There are many! -# Most important is to give InnoDB 80 % of the system RAM for buffer use: -# https://mariadb.com/kb/en/innodb-system-variables/#innodb_buffer_pool_size -#innodb_buffer_pool_size = 8G - # this is only for embedded server [embedded] @@ -212,7 +256,6 @@ collation-server = utf8mb4_general_ci # If you use the same .cnf file for MariaDB of different versions, # use this group for options that older servers don't understand [mariadb-10.5] - # # * Galera-related settings # @@ -234,7 +277,12 @@ collation-server = utf8mb4_general_ci #wsrep_slave_threads=1 #innodb_flush_log_at_trx_commit=0 +[isamchk] +key_buffer = 16M -# Import all .cnf files from configuration directory +# +# * 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/ !includedir /etc/mysql/mariadb.conf.d/ From f9e738c3ec46c674726889bb6d746ae158956827 Mon Sep 17 00:00:00 2001 From: Kirtan Gajjar Date: Thu, 5 Nov 2020 18:04:22 +0530 Subject: [PATCH 3/3] Remove default config files before adding new ones --- mariadb/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/mariadb/Dockerfile b/mariadb/Dockerfile index 224d922..43fe0b6 100644 --- a/mariadb/Dockerfile +++ b/mariadb/Dockerfile @@ -3,5 +3,6 @@ LABEL org.label-schema.schema-version="1.0.0-rc1" LABEL org.label-schema.vendor="EasyEngine" LABEL org.label-schema.name="db" +RUN rm /etc/mysql/my.cnf && rm /etc/mysql/mariadb.cnf && rm /etc/mysql/mariadb.conf.d/* COPY ee.cnf /etc/mysql/conf.d/ee.cnf COPY my.cnf /etc/mysql/ \ No newline at end of file