From 8b9bb4e7d71fde24fc43cb9e978f6e6ce5a26992 Mon Sep 17 00:00:00 2001 From: Philippe Caseiro Date: Wed, 11 Apr 2018 17:00:18 +0200 Subject: [PATCH] Adding Tunning Options --- creolefuncs/mariadb.py | 13 +++++++++ dicos/25_bdd_server.xml | 61 ++++++++++++++++++++++++++++++++++++++++ postservice/25-bdd-admin | 7 +++++ tmpl/galera.cnf | 2 ++ tmpl/tunning.cnf | 26 +++++++++++++++++ 5 files changed, 109 insertions(+) create mode 100644 creolefuncs/mariadb.py create mode 100644 tmpl/tunning.cnf diff --git a/creolefuncs/mariadb.py b/creolefuncs/mariadb.py new file mode 100644 index 0000000..39702a0 --- /dev/null +++ b/creolefuncs/mariadb.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- + +def getMemoryPercentage(percent): + import os + try: + percent = int(percent) + totalMemory = os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') + memoryToUse = (totalMemory*percent)/100 + memoryMb = memoryToUse/(1024.**2) + return "{0}M".format(round(memoryMb,2)) + except: + return "Error during memory percentage calculation" + diff --git a/dicos/25_bdd_server.xml b/dicos/25_bdd_server.xml index 8434a8a..1590544 100644 --- a/dicos/25_bdd_server.xml +++ b/dicos/25_bdd_server.xml @@ -1,6 +1,7 @@ + 3306 mariadb @@ -44,6 +45,50 @@ + + + + + 20 + + + 100 + + + 16 + + + non + + + 900K + + + 2K + + + 80M + + + 64M + + + non + + + /var/log/mysql/slow-query.log + + + 1 + + + 20 + + + non + + + @@ -65,6 +110,9 @@ rsync + + 128 + @@ -121,6 +169,19 @@ Database dbCluster + + + non + dbQueryCacheLimit + dbQueryCacheMinRestUnit + dbQueryCacheSize + + + + non + dbSlowQueryLogTime + dbSlowQueryLogFile + diff --git a/postservice/25-bdd-admin b/postservice/25-bdd-admin index ecf49b0..8d12fce 100755 --- a/postservice/25-bdd-admin +++ b/postservice/25-bdd-admin @@ -1,6 +1,7 @@ #!/bin/bash todo=$(CreoleGet dbCreateFixAdmin 'non') +autoRepair=$(CreoleGet dbAutoOptimizeAndRepare 'non') if [[ ${todo} != 'non' ]] then @@ -60,5 +61,11 @@ then chmod 600 ${readerfile} rm -rf ${sqlFile} fi + +if [[ ${autoRepair} == "oui" ]] +then + mysqlcheck -u root --auto-repair --check --optimize --all-databases +fi + exit 0 diff --git a/tmpl/galera.cnf b/tmpl/galera.cnf index 1d14a0b..94cab58 100644 --- a/tmpl/galera.cnf +++ b/tmpl/galera.cnf @@ -15,6 +15,8 @@ wsrep_cluster_address="gcomm://%%nodeIP%slurp %end for " +# Tunning +wsrep_provider_options="gcache.size=%%dbClusterGcacheSizeMb" # Galera Synchronization Configuration wsrep_sst_method=%%dbSSTMethod diff --git a/tmpl/tunning.cnf b/tmpl/tunning.cnf new file mode 100644 index 0000000..fc0d5e1 --- /dev/null +++ b/tmpl/tunning.cnf @@ -0,0 +1,26 @@ +[mysqld] +innodb_file_per_table=1 +skip-name-resolve + +innodb_buffer_pool_size=%%getMemoryPercentage(%%getVar('dbInnoDBBufferPoolPercentage', 10)) +max_connections=%%dbMaxConnections +thread_cache_size=%%dbThreadCacheSize + +%if %%dbCacheQueryEnable == 'oui' +query_cache_type = 1 +query_cache_limit = %%dbQueryCacheLimit +query_cache_min_res_unit = %%dbQueryCacheMinResUint +query_cache_size = %%dbQueryCacheSize +%end if + +tmp_table_size = %%dbTmpTableSize +max_heap_table_size = %%dbTmpTableSize + +%if %%dbEnableSlowQueryLogs == "oui" +slow-query-log = 1 +slow-query-log-file = %%dbSlowQueryLogFile +long_query_time = %%dbSlowQueryLogTime +%end if + +wait_timeout = %%dbWaitTimeout +