From 62483d0a01b977020228818c24fbbcaf4f29cfd3 Mon Sep 17 00:00:00 2001 From: Razvan-Liviu Varzaru Date: Wed, 4 Dec 2024 10:50:10 +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. - old_mode = '' to allow utf8mb4 on the connection. Emoji's can now be inserted into buildbot.changes.comments - cleaned PROD configuration where default/harmful options were present. - pinned MariaDB Server version to 10.11.10 to be in control of minor upgrades. - switched to standard healthcheck script for containers - moved datadir to /srv/mariadb --- docker-compose/docker-compose.yaml | 8 ++-- docker-compose/generate-config.py | 9 ++-- docker-compose/mariadb-config/dev/mariadb.cnf | 17 +++++++ .../mariadb-config/prod/mariadb.cnf | 44 +++++++++++++++++++ docker-compose/mariadb.cnf | 8 ---- rsync.exclude | 1 - 6 files changed, 70 insertions(+), 17 deletions(-) create mode 100644 docker-compose/mariadb-config/dev/mariadb.cnf create mode 100644 docker-compose/mariadb-config/prod/mariadb.cnf delete mode 100644 docker-compose/mariadb.cnf diff --git a/docker-compose/docker-compose.yaml b/docker-compose/docker-compose.yaml index 310fc444..9bce8cac 100644 --- a/docker-compose/docker-compose.yaml +++ b/docker-compose/docker-compose.yaml @@ -3,7 +3,7 @@ --- services: mariadb: - image: mariadb:10.11 + image: mariadb:10.11.10 restart: unless-stopped container_name: mariadb hostname: mariadb @@ -15,10 +15,10 @@ services: - MARIADB_AUTO_UPGRADE=1 network_mode: host healthcheck: - test: ['CMD', "mariadb-admin", "--password=password", "--protocol", "tcp", "ping"] + test: ['CMD', "healthcheck.sh", "--connect", "--innodb_initialized"] volumes: - - ./mariadb:/var/lib/mysql:rw - - ./mariadb.cnf:/etc/mysql/conf.d/mariadb.cnf:ro + - /srv/mariadb:/var/lib/mysql:rw + - ./mariadb-config/dev/mariadb.cnf:/etc/mysql/conf.d/mariadb.cnf:ro logging: driver: journald options: diff --git a/docker-compose/generate-config.py b/docker-compose/generate-config.py index 354b7940..669658c8 100755 --- a/docker-compose/generate-config.py +++ b/docker-compose/generate-config.py @@ -29,7 +29,7 @@ --- services: mariadb: - image: mariadb:10.11 + image: mariadb:10.11.10 restart: unless-stopped container_name: mariadb hostname: mariadb @@ -41,10 +41,10 @@ - MARIADB_AUTO_UPGRADE=1 network_mode: host healthcheck: - test: ['CMD', "mariadb-admin", "--password=password", "--protocol", "tcp", "ping"] + test: ['CMD', "healthcheck.sh", "--connect", "--innodb_initialized"] volumes: - - ./mariadb:/var/lib/mysql:rw - - ./mariadb.cnf:/etc/mysql/conf.d/mariadb.cnf:ro + - /srv/mariadb:/var/lib/mysql:rw + - ./mariadb-config/{config_path}/mariadb.cnf:/etc/mysql/conf.d/mariadb.cnf:ro logging: driver: journald options: @@ -194,6 +194,7 @@ def main(args): start_template.format( port=master_web_port, environment="" if args.env == "prod" else "dev_", + config_path=args.env, ) ) port = starting_port diff --git a/docker-compose/mariadb-config/dev/mariadb.cnf b/docker-compose/mariadb-config/dev/mariadb.cnf new file mode 100644 index 00000000..64824881 --- /dev/null +++ b/docker-compose/mariadb-config/dev/mariadb.cnf @@ -0,0 +1,17 @@ +[mariadb] + +# InnoDB +innodb_buffer_pool_size = 4G +innodb_log_file_size = 4G +innodb_io_capacity = 2000 + +# Logging +slow_query_log +log_slow_query_file = mariadb-slow.log +log_slow_verbosity = full +log_slow_query_time = 2 + +# Character sets +character-set-server = utf8mb4 +collation-server = utf8mb4_uca1400_ai_ci +old_mode = '' diff --git a/docker-compose/mariadb-config/prod/mariadb.cnf b/docker-compose/mariadb-config/prod/mariadb.cnf new file mode 100644 index 00000000..2cc848f4 --- /dev/null +++ b/docker-compose/mariadb-config/prod/mariadb.cnf @@ -0,0 +1,44 @@ +[mariadb] + +# Fine tuning +max_connections = 300 +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 +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 +log_slow_query +log_slow_query_file = mariadb-slow.log +log_slow_query_time = 2 +log_slow_verbosity = full + +# Character sets +character-set-server = utf8mb4 +collation-server = utf8mb4_uca1400_ai_ci +old_mode = '' + +# 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 + diff --git a/docker-compose/mariadb.cnf b/docker-compose/mariadb.cnf deleted file mode 100644 index 3f87cada..00000000 --- a/docker-compose/mariadb.cnf +++ /dev/null @@ -1,8 +0,0 @@ -[mariadb] - -slow_query_log -log_slow_verbosity = query_plan,explain,engine -log_slow_query_time = 0.5 -innodb_buffer_pool_size = 4G # FIXME: find a solution for DEV and PROD not being ISO -innodb_log_file_size = 4G # FIXME: find a solution for DEV and PROD not being ISO -innodb_io_capacity = 2000 diff --git a/rsync.exclude b/rsync.exclude index e5ff42b9..1a53618b 100644 --- a/rsync.exclude +++ b/rsync.exclude @@ -6,7 +6,6 @@ autogen ci_build_images docker-compose/logs docker-compose/certbot -docker-compose/mariadb docker-compose/nginx/conf.d/bb.conf docker-compose/nginx/conf.d/ci.conf master-libvirt/id_ed25519