From b5b8049c3b4a69b821cd3002abe71f00b6bbceab Mon Sep 17 00:00:00 2001 From: Jorge Niedbalski Date: Thu, 4 Jun 2015 11:40:54 -0300 Subject: [PATCH] Fixes bug LP: #1461669 --- config.yaml | 10 +++++++++- hooks/charmhelpers/contrib/database/mysql.py | 20 +++++++++++--------- templates/my.cnf | 2 +- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/config.yaml b/config.yaml index 8259482..540af2e 100644 --- a/config.yaml +++ b/config.yaml @@ -10,7 +10,7 @@ options: Key ID to import to the apt keyring to support use with arbitary source configuration from outside of Launchpad archives or PPA's. dataset-size: - default: '80%' + default: type: string description: How much data do you want to keep in memory in the DB. This will be used to tune settings in the database server appropriately. Suffix this value with 'K','M','G', or 'T' to get the relevant kilo/mega/etc. bytes. If suffixed with %, one will get that percentage of RAM devoted to dataset. max-connections: @@ -103,3 +103,11 @@ options: description: | A comma-separated list of nagios servicegroups. If left empty, the nagios_context will be used as the servicegroup + innodb-buffer-pool-size: + default: + type: string + description: | + By default this value will be set according to the 50% of system total memory + but also can be set to any specific value for the system. + Suffix this value with 'K','M','G', or 'T' to get the relevant kilo/mega/etc. bytes. + If suffixed with %, one will get that percentage of system total memory devoted. \ No newline at end of file diff --git a/hooks/charmhelpers/contrib/database/mysql.py b/hooks/charmhelpers/contrib/database/mysql.py index 2efd6ff..f2cece7 100644 --- a/hooks/charmhelpers/contrib/database/mysql.py +++ b/hooks/charmhelpers/contrib/database/mysql.py @@ -385,23 +385,25 @@ class PerconaClusterHelper(object): mysql_config['key_buffer'] = self.human_to_bytes('32M') total_memory = self.human_to_bytes(self.get_mem_total()) - log("Option 'dataset-size' has been deprecated, instead by default %d%% of system \ - available RAM will be used for innodb_buffer_pool_size allocation" % - (self.DEFAULT_INNODB_BUFFER_FACTOR * 100), level="WARN") - + dataset_bytes = config.get('dataset-size', None) innodb_buffer_pool_size = config.get('innodb-buffer-pool-size', None) if innodb_buffer_pool_size: innodb_buffer_pool_size = self.human_to_bytes( innodb_buffer_pool_size) - - if innodb_buffer_pool_size > total_memory: - log("innodb_buffer_pool_size; {} is greater than system available memory:{}".format( - innodb_buffer_pool_size, - total_memory), level='WARN') + elif dataset_bytes: + log("Option 'dataset-size' has been deprecated, please use" + "innodb_buffer_pool_size option instead", level="WARN") + innodb_buffer_pool_size = self.human_to_bytes( + dataset_bytes) else: innodb_buffer_pool_size = int( total_memory * self.DEFAULT_INNODB_BUFFER_FACTOR) + if innodb_buffer_pool_size > total_memory: + log("innodb_buffer_pool_size; {} is greater than system available memory:{}".format( + innodb_buffer_pool_size, + total_memory), level='WARN') + mysql_config['innodb_buffer_pool_size'] = innodb_buffer_pool_size return mysql_config diff --git a/templates/my.cnf b/templates/my.cnf index 2acee48..c3b59c5 100644 --- a/templates/my.cnf +++ b/templates/my.cnf @@ -72,7 +72,7 @@ max_allowed_packet = 16M # InnoDB buffer should consume 100% of the bytes of the dataset size # query cache is not supported with Active/Active configuration -innodb_buffer_pool_size = {{ dataset_bytes }} +innodb_buffer_pool_size = {{ innodb_buffer_pool_size }} {% if ipv6 -%} [sst]