From 9660e49bdf8229418450c9a1151ab217d357a797 Mon Sep 17 00:00:00 2001 From: Andrii Petrenko Date: Thu, 14 Jan 2016 08:30:54 -0800 Subject: [PATCH] Tweak MySQL logging configuration For a galera replication we do not need binary logs, but we need binary logs in case customer needs to perform MySQL backup. In this review we propose to limit rotation period for 1 day, and set option to disable binary logging by default. Change-Id: I001c87081a3b334eb8844abca60e468370ea5f24 Closes-Bug: #1533805 --- deployment/puppet/galera/manifests/init.pp | 17 +++++++++++++++++ .../puppet/galera/templates/wsrep.cnf.erb | 7 +++++-- tests/noop/spec/hosts/database/database_spec.rb | 6 ++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/deployment/puppet/galera/manifests/init.pp b/deployment/puppet/galera/manifests/init.pp index 736bed53c1..7f25ab34c9 100644 --- a/deployment/puppet/galera/manifests/init.pp +++ b/deployment/puppet/galera/manifests/init.pp @@ -63,6 +63,20 @@ # system at install time. NOTE: use_percona must be set to true for this to # be used. # +# [*binary_logs_enabled*] +# Set this value to true for enabling MySQL binary logging. +# Defaults to false +# +# [*binary_logs_period*] +# (optional) Set binary logrotation period in days. +# Defaults to 1 +# +# [*binary_logs_maxsize*] +# (optional) If a write to the binary log causes the current log file +# size to exceed the value of this variable, the server rotates the +# binary logs (closes the current file and opens the next one). The +# minimum value is 4096 bytes. The maximum and default value is 512MB. + class galera ( $cluster_name = 'openstack', $primary_controller = false, @@ -78,6 +92,9 @@ class galera ( $wsrep_sst_password = undef, $use_percona = false, $use_percona_packages = false, + $binary_logs_enabled = false, + $binary_logs_period = 1, + $binary_logs_maxsize = '512M', ) { include galera::params diff --git a/deployment/puppet/galera/templates/wsrep.cnf.erb b/deployment/puppet/galera/templates/wsrep.cnf.erb index a892b15eeb..90c4b9b6a8 100644 --- a/deployment/puppet/galera/templates/wsrep.cnf.erb +++ b/deployment/puppet/galera/templates/wsrep.cnf.erb @@ -5,12 +5,15 @@ port=3307 max_connections=<%= @max_connections %> default-storage-engine=innodb binlog_format=ROW -log_bin=mysql-bin collation-server=utf8_general_ci init-connect='SET NAMES utf8' character-set-server=utf8 default-storage-engine=innodb -expire_logs_days=10 +<% if @binary_logs_enabled -%> +log_bin=mysql-bin +expire_logs_days=<%= @binary_logs_period %> +max_binlog_size=<%= @binary_logs_maxsize %> +<% end -%> skip-external-locking <% if @skip_name_resolve -%> diff --git a/tests/noop/spec/hosts/database/database_spec.rb b/tests/noop/spec/hosts/database/database_spec.rb index a028d753b1..00643594da 100644 --- a/tests/noop/spec/hosts/database/database_spec.rb +++ b/tests/noop/spec/hosts/database/database_spec.rb @@ -62,6 +62,12 @@ describe manifest do provider = nil end + it { + should contain_file('/etc/mysql/conf.d/wsrep.cnf').without( + :content => /.*log_bin=mysql-bin.*/, + ) + } + it { should contain_haproxy_backend_status('mysql').with( :url => url,