From 7950a2ea47204aab0174ae1505c5da98c19bd7d4 Mon Sep 17 00:00:00 2001 From: Razvan-Liviu Varzaru Date: Wed, 27 Nov 2024 16:49:30 +0200 Subject: [PATCH] MDBF-829 - Update MariaDB Server cnf Separate configs for PROD and DEV. Updated docker-compose to choose the right one based on environment. TODO: maybe a templating engine in the future to de-deduplicate configuration settings. Took all the configuration settings from current PROD MariaDB Server installation. --- docker-compose/docker-compose.yaml | 3 +- docker-compose/generate-config.py | 7 ++- .../{ => mariadb-config/dev}/mariadb.cnf | 0 .../mariadb-config/prod/mariadb.cnf | 58 +++++++++++++++++++ 4 files changed, 65 insertions(+), 3 deletions(-) rename docker-compose/{ => mariadb-config/dev}/mariadb.cnf (100%) create mode 100644 docker-compose/mariadb-config/prod/mariadb.cnf diff --git a/docker-compose/docker-compose.yaml b/docker-compose/docker-compose.yaml index 2ba99904..64e93450 100644 --- a/docker-compose/docker-compose.yaml +++ b/docker-compose/docker-compose.yaml @@ -18,7 +18,8 @@ services: test: ['CMD', "mariadb-admin", "--password=password", "--protocol", "tcp", "ping"] volumes: - ./mariadb:/var/lib/mysql:rw - - ./mariadb.cnf:/etc/mysql/conf.d/mariadb.cnf:ro + - ./mariadb-config/dev/mariadb.cnf:/etc/mysql/conf.d/mariadb.cnf:ro + - ./logs/mariadb:/var/log/mysql logging: driver: journald options: diff --git a/docker-compose/generate-config.py b/docker-compose/generate-config.py index 0d42bf40..cd782ecd 100755 --- a/docker-compose/generate-config.py +++ b/docker-compose/generate-config.py @@ -44,7 +44,8 @@ test: ['CMD', "mariadb-admin", "--password=password", "--protocol", "tcp", "ping"] volumes: - ./mariadb:/var/lib/mysql:rw - - ./mariadb.cnf:/etc/mysql/conf.d/mariadb.cnf:ro + - ./mariadb-config/{config_path}/mariadb.cnf:/etc/mysql/conf.d/mariadb.cnf:ro + - ./logs/mariadb:/var/log/mysql logging: driver: journald options: @@ -192,7 +193,9 @@ def main(args): ) file.write( start_template.format( - port=master_web_port, cr_host_wg_addr=env_vars["CR_HOST_WG_ADDR"] + port=master_web_port, + cr_host_wg_addr=env_vars["CR_HOST_WG_ADDR"], + config_path=args.env, ) ) port = starting_port diff --git a/docker-compose/mariadb.cnf b/docker-compose/mariadb-config/dev/mariadb.cnf similarity index 100% rename from docker-compose/mariadb.cnf rename to docker-compose/mariadb-config/dev/mariadb.cnf diff --git a/docker-compose/mariadb-config/prod/mariadb.cnf b/docker-compose/mariadb-config/prod/mariadb.cnf new file mode 100644 index 00000000..9aa0c35f --- /dev/null +++ b/docker-compose/mariadb-config/prod/mariadb.cnf @@ -0,0 +1,58 @@ +[mariadb] + +port = 3306 +bind-address = 0.0.0.0 + +# Fine tuning +max_connections = 300 +connect_timeout = 5 +wait_timeout = 600 +max_allowed_packet = 32M +thread_cache_size = 128 +sort_buffer_size = 128M +bulk_insert_buffer_size = 128M +tmp_table_size = 32M +max_heap_table_size = 32M +skip-name-resolve = 1 +innodb_log_file_size = 2G + +# Logging +# warning log-basename is defined later for replication +# some log option may be ignored. +# see: https://mariadb.com/kb/en/mysqld-options/#-log-basename +# log_error = /var/log/mysql/error.log +slow_query_log +slow_query_log_file = /var/log/mysql/mariadb-slow.log +long_query_time = 2 +log_slow_verbosity = query_plan,explain +log_error = /var/log/mysql/mariadb.err.log + +# Query cache +query_cache_size = 16M + +# Character sets +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! +innodb_buffer_pool_size = 40G + +# Replication +server-id = 1 +log-basename = mariadb + +log_bin +expire_logs_days = 5 +max_binlog_size = 100M +binlog_format = MIXED +# the following permits to simplify the process of moving a replica to a +# primary node role by ensuring that replication is not started on primary node +skip-slave-start + + +[mysqldump] +quick +quote-names +max_allowed_packet = 16M