Skip to content

Commit

Permalink
MDBF-829 - Update MariaDB Server cnf
Browse files Browse the repository at this point in the history
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
  • Loading branch information
RazvanLiviuVarzaru committed Dec 4, 2024
1 parent 050c1bb commit 62483d0
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 17 deletions.
8 changes: 4 additions & 4 deletions docker-compose/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
---
services:
mariadb:
image: mariadb:10.11
image: mariadb:10.11.10
restart: unless-stopped
container_name: mariadb
hostname: mariadb
Expand All @@ -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:
Expand Down
9 changes: 5 additions & 4 deletions docker-compose/generate-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
---
services:
mariadb:
image: mariadb:10.11
image: mariadb:10.11.10
restart: unless-stopped
container_name: mariadb
hostname: mariadb
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions docker-compose/mariadb-config/dev/mariadb.cnf
Original file line number Diff line number Diff line change
@@ -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 = ''
44 changes: 44 additions & 0 deletions docker-compose/mariadb-config/prod/mariadb.cnf
Original file line number Diff line number Diff line change
@@ -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

8 changes: 0 additions & 8 deletions docker-compose/mariadb.cnf

This file was deleted.

1 change: 0 additions & 1 deletion rsync.exclude
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 62483d0

Please sign in to comment.