From 22e0fd4d4bdd089abfc467b619c470941c532766 Mon Sep 17 00:00:00 2001 From: Sebastien Badia Date: Sat, 4 Jan 2014 15:50:36 +0100 Subject: [PATCH] database: migrate galera config to a full template --- manifests/database/sql.pp | 72 ++----------------- .../classes/privatecloud_database_sql_spec.rb | 2 +- templates/database/mysql.conf.erb | 69 ++++++++++++++++++ 3 files changed, 74 insertions(+), 69 deletions(-) create mode 100644 templates/database/mysql.conf.erb diff --git a/manifests/database/sql.pp b/manifests/database/sql.pp index b8f3ac02..a58f5073 100644 --- a/manifests/database/sql.pp +++ b/manifests/database/sql.pp @@ -59,6 +59,9 @@ class privatecloud::database::sql ( 'Debian': { $package_name = 'mariadb-galera-server' } + default: { + err "${::osfamily} not supported yet" + } } class { 'mysql::server': @@ -184,74 +187,7 @@ basedir = /usr mysql::server::config{'basic_config': notify_service => false, notify => Exec['clean-mysql-binlog'], - settings => inline_template(' -[mysqld] -max_connections = 1000 -connect_timeout = 5 -wait_timeout = 600 -max_allowed_packet = 64M -thread_cache_size = 128 -sort_buffer_size = 4M -bulk_insert_buffer_size = 16M -tmp_table_size = 128M -max_heap_table_size = 128M -query_cache_limit = 1M -query_cache_size = 16M -myisam_recover = BACKUP -key_buffer_size = 16M -open-files-limit = 65535 -table_open_cache = 500 -table_definition_cache = 500 -myisam_sort_buffer_size = 512M -concurrent_insert = 2 -read_buffer_size = 2M -read_rnd_buffer_size = 1M -slow_query_log = 1 -slow_query_log_file = /var/log/mysql/slow.log -log_error = /var/log/mysql/error.log -long_query_time = 1 -log_slow_verbosity = query_plan -innodb_buffer_pool_size = 64M -innodb_flush_log_at_trx_commit = 1 -innodb_lock_wait_timeout = 50 -innodb_thread_concurrency = 48 -innodb_file_per_table = 1 -innodb_open_files = 65535 -innodb_io_capacity = 1000 -innodb_file_format = Barracuda -innodb_file_format_max = Barracuda -innodb_max_dirty_pages_pct = 50 -binlog_format = ROW -innodb_autoinc_lock_mode = 2 -innodb_locks_unsafe_for_binlog = 1 -wsrep_provider = /usr/lib/galera/libgalera_smm.so -wsrep_cluster_name = "galera_cluster" -<%- if hostname != galera_master -%> -# This node is Galera Master -wsrep_cluster_address = "gcomm://<%= @galera_nextserver[@galera_master] %>" -<%- else -%> -# This node is not Galera Master -wsrep_cluster_address = "gcomm://" -<%- end -%> -wsrep_sst_auth = root:<%= scope.lookupvar("$mysql_password") %> -wsrep_certify_nonPK = 1 -wsrep_convert_LOCK_to_trx = 0 -wsrep_auto_increment_control = 1 -wsrep_drupal_282555_workaround = 0 -wsrep_causal_reads = 0 -wsrep_sst_method = rsync -wsrep_node_address = "<%= @api_eth %>" -wsrep_node_incoming_address = "<%= @api_eth %>" -# this value here are used by /usr/bin/innobackupex -# and wsrep_sst_xtrabackup take only one configuration file and use the last one -# (/etc/mysql/my.cnf is not used) -datadir = /var/lib/mysql -tmpdir = /tmp -innodb_flush_method = O_DIRECT -innodb_log_buffer_size = 32M -innodb_log_file_size = 256M -innodb_log_files_in_group = 2 -'), + settings => template('privatecloud/database/mysql.conf.erb'), } exec{'clean-mysql-binlog': diff --git a/spec/classes/privatecloud_database_sql_spec.rb b/spec/classes/privatecloud_database_sql_spec.rb index f13ec2f2..6d75c13a 100644 --- a/spec/classes/privatecloud_database_sql_spec.rb +++ b/spec/classes/privatecloud_database_sql_spec.rb @@ -63,7 +63,7 @@ describe 'privatecloud::database::sql' do should contain_class('mysql::server').with( :package_name => platform_params[:package_name], :service_name => 'mysql', - :config_hash => { :bind_address => '10.0.0.1', :root_password => 'secrete' }, + :config_hash => { 'bind_address' => '10.0.0.1', 'root_password' => 'secrete' }, :notify => 'Service[xinetd]' ) end diff --git a/templates/database/mysql.conf.erb b/templates/database/mysql.conf.erb new file mode 100644 index 00000000..a07e0e14 --- /dev/null +++ b/templates/database/mysql.conf.erb @@ -0,0 +1,69 @@ +# MANAGED BY PUPPET +# Module:: privatecloud::database::sql +# +[mysqld] +max_connections = 1000 +connect_timeout = 5 +wait_timeout = 600 +max_allowed_packet = 64M +thread_cache_size = 128 +sort_buffer_size = 4M +bulk_insert_buffer_size = 16M +tmp_table_size = 128M +max_heap_table_size = 128M +query_cache_limit = 1M +query_cache_size = 16M +myisam_recover = BACKUP +key_buffer_size = 16M +open-files-limit = 65535 +table_open_cache = 500 +table_definition_cache = 500 +myisam_sort_buffer_size = 512M +concurrent_insert = 2 +read_buffer_size = 2M +read_rnd_buffer_size = 1M +slow_query_log = 1 +slow_query_log_file = /var/log/mysql/slow.log +log_error = /var/log/mysql/error.log +long_query_time = 1 +log_slow_verbosity = query_plan +innodb_buffer_pool_size = 64M +innodb_flush_log_at_trx_commit = 1 +innodb_lock_wait_timeout = 50 +innodb_thread_concurrency = 48 +innodb_file_per_table = 1 +innodb_open_files = 65535 +innodb_io_capacity = 1000 +innodb_file_format = Barracuda +innodb_file_format_max = Barracuda +innodb_max_dirty_pages_pct = 50 +binlog_format = ROW +innodb_autoinc_lock_mode = 2 +innodb_locks_unsafe_for_binlog = 1 +wsrep_provider = /usr/lib/galera/libgalera_smm.so +wsrep_cluster_name = "galera_cluster" +<% if @hostname != @galera_master -%> +# This node is not Galera Master (connect wsrep to galera_master) +wsrep_cluster_address = "gcomm://<%= @galera_nextserver[0] %>" +<% else -%> +# This node is Galera Master (connect wsrep to localhost) +wsrep_cluster_address = "gcomm://" +<% end -%> +wsrep_sst_auth = root:<%= @mysql_password %> +wsrep_certify_nonPK = 1 +wsrep_convert_LOCK_to_trx = 0 +wsrep_auto_increment_control = 1 +wsrep_drupal_282555_workaround = 0 +wsrep_causal_reads = 0 +wsrep_sst_method = rsync +wsrep_node_address = "<%= @api_eth %>" +wsrep_node_incoming_address = "<%= @api_eth %>" +# this value here are used by /usr/bin/innobackupex +# and wsrep_sst_xtrabackup take only one configuration file and use the last one +# (/etc/mysql/my.cnf is not used) +datadir = /var/lib/mysql +tmpdir = /tmp +innodb_flush_method = O_DIRECT +innodb_log_buffer_size = 32M +innodb_log_file_size = 256M +innodb_log_files_in_group = 2