Tune MariaDB config generation

This commit is contained in:
Marek Miklewicz
2026-06-13 20:49:00 +02:00
parent d0ac04f38b
commit db01ba1ea0
4 changed files with 356 additions and 55 deletions
+22
View File
@@ -69,6 +69,7 @@ assert_plain_tar_archive_clean_for_linux_tar() {
assert_bash_syntax "$ROOT_DIR/dapostinstall.sh"
assert_bash_syntax "$ROOT_DIR/da_cli.sh"
assert_bash_syntax "$ROOT_DIR/daupdate.sh"
assert_bash_syntax "$ROOT_DIR/my-cnf-gen.sh"
php -l "$ROOT_DIR/lang_pl.php" >/dev/null || fail "lang_pl.php has invalid PHP syntax"
assert_archive_clean_for_linux_tar "$ROOT_DIR/spolszczenie_enhanced.tar.gz"
@@ -194,6 +195,21 @@ assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'redis_migrate\.sh'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'redis_management\.tar\.gz'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'plugins/redis_management'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'tar -zxf imapsync\.tar\.gz'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'bash "\$DAPOSTINSTALL_DIR/my-cnf-gen\.sh" --output /etc/my\.cnf'
assert_file_contains "$ROOT_DIR/my.cnf" 'character-set-server=utf8mb4'
assert_file_contains "$ROOT_DIR/my.cnf" 'collation-server=utf8mb4_unicode_ci'
assert_file_contains "$ROOT_DIR/my.cnf" 'query_cache_type=0'
assert_file_contains "$ROOT_DIR/my.cnf" 'query_cache_size=0'
assert_file_not_contains "$ROOT_DIR/my.cnf" 'query-cache-type'
assert_file_not_contains "$ROOT_DIR/my.cnf" 'query-cache-size'
assert_file_not_contains "$ROOT_DIR/my.cnf" 'innodb_file_format'
assert_file_contains "$ROOT_DIR/my-cnf-gen.sh" 'MARIADB_MEMORY_PERCENT=25'
assert_file_contains "$ROOT_DIR/my-cnf-gen.sh" 'MYSQL_GEN_MEM_MB'
assert_file_contains "$ROOT_DIR/my-cnf-gen.sh" 'MYSQL_GEN_CPU_CORES'
assert_file_contains "$ROOT_DIR/my-cnf-gen.sh" '/proc/meminfo'
assert_file_contains "$ROOT_DIR/my-cnf-gen.sh" '/proc/cpuinfo'
assert_file_contains "$ROOT_DIR/my-cnf-gen.sh" 'innodb_buffer_pool_size'
assert_file_contains "$ROOT_DIR/my-cnf-gen.sh" 'MariaDB 10.6'
assert_file_contains "$ROOT_DIR/mail_powitalny.txt" '\{\{DA_HOSTNAME\}\}'
assert_file_contains "$ROOT_DIR/mail_powitalny.txt" '\{\{DA_HASLO\}\}'
assert_file_contains "$ROOT_DIR/mail_powitalny.txt" '\{\{DA_PHP_LIST\}\}'
@@ -210,6 +226,12 @@ source "$COMMON_SH"
tmp_dir="$(mktemp -d)"
trap 'rm -rf "$tmp_dir"' EXIT
generated_my_cnf="$tmp_dir/generated-my.cnf"
MYSQL_GEN_MEM_MB=8192 MYSQL_GEN_CPU_CORES=4 "$ROOT_DIR/my-cnf-gen.sh" --output "$generated_my_cnf"
grep -qx 'innodb_buffer_pool_size=2G' "$generated_my_cnf" || fail "generated my.cnf should allocate 25% of 8G to InnoDB"
grep -qx 'max_connections=80' "$generated_my_cnf" || fail "generated my.cnf should keep low-RAM max_connections conservative"
grep -qx 'query_cache_size=0' "$generated_my_cnf" || fail "generated my.cnf should disable query cache"
kv_file="$tmp_dir/example.conf"
printf 'ns1=old.example\nother=value\n' > "$kv_file"
set_key_value "$kv_file" "ns1" "dns3.hitme.net.pl"