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.
TODO: maybe a templating engine in the future to de-deduplicate configuration settings.

Took all the configuration settings from current PROD MariaDB Server installation.
  • Loading branch information
RazvanLiviuVarzaru committed Nov 27, 2024
1 parent ceecd9c commit 7950a2e
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docker-compose/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 5 additions & 2 deletions docker-compose/generate-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
File renamed without changes.
58 changes: 58 additions & 0 deletions docker-compose/mariadb-config/prod/mariadb.cnf
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7950a2e

Please sign in to comment.