From 7e107a1cf5fa0134318ce119481db7a3e679bf72 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Mon, 23 Sep 2024 14:11:41 +0200 Subject: [PATCH 01/32] Initial attempt of a backup class Most of it is copied from Sunet Drive --- manifests/mariadb.pp | 3 + manifests/mariadb/backup.pp | 76 +++++++++++++++++++ .../mariadb/backup/check_replication.erb | 10 +++ templates/mariadb/backup/do_backup.erb.sh | 12 +++ .../backup/start_replica_from_init.erb.sh | 17 +++++ templates/mariadb/backup/status-test.erb | 3 + .../mariadb/docker-compose_mariadb.yml.erb | 7 ++ templates/mariadb/my.cnf.erb | 2 + 8 files changed, 130 insertions(+) create mode 100644 manifests/mariadb/backup.pp create mode 100755 templates/mariadb/backup/check_replication.erb create mode 100644 templates/mariadb/backup/do_backup.erb.sh create mode 100644 templates/mariadb/backup/start_replica_from_init.erb.sh create mode 100644 templates/mariadb/backup/status-test.erb diff --git a/manifests/mariadb.pp b/manifests/mariadb.pp index b96f305ed..1994e8f4f 100644 --- a/manifests/mariadb.pp +++ b/manifests/mariadb.pp @@ -6,6 +6,9 @@ Array[String] $dns = [], ) { + + $galera = true + $mariadb_root_password = lookup('mariadb_root_password', undef, undef,'NOT_SET_IN_HIERA') $mariadb_user = lookup('mariadb_user', undef, undef,undef) $mariadb_user_password = lookup('mariadb_user_password', undef, undef,undef) diff --git a/manifests/mariadb/backup.pp b/manifests/mariadb/backup.pp new file mode 100644 index 000000000..d532a6d57 --- /dev/null +++ b/manifests/mariadb/backup.pp @@ -0,0 +1,76 @@ +# This is a asyncronous replica of the Maria DB Cluster for SUNET +class sunet::mariadb::backup( + $tag_mariadb=undef, + $location=undef +) { + + include sunet::packages::netcat_openbsd + $dirs = [ 'datadir', 'init', 'conf', 'backups' ] + $dirs.each | $dir | { + ensure_resource('file',"/opt/mariadb/backup/${dir}", { ensure => directory, recurse => true } ) + } + + $cluster_nodes = lookup('mariadb_cluster_nodes', undef, undef,[]) + $replicate_from = cluster_nodes[0] + + # Secrets from local.eyaml + $mysql_root_password = safe_hiera('mariadb_root_password') + $backup_password = safe_hiera('mariadb_root_password') + $mysql_user_password = safe_hiera('mariadb_user_password') + + sunet::system_user {'mysql': username => 'mysql', group => 'mysql' } + + $sql_files = ['02-backup_user.sql'] + $sql_files.each |$sql_file|{ + file { "/opt/mariadb/backup/init/${sql_file}": + ensure => present, + content => template("sunet/mariadb/${sql_file}.erb"), + mode => '0744', + } + } + $conf_files = ['credentials.cnf', 'my.cnf'] + $conf_files.each |$conf_file|{ + file { "/opt/mariadb/backup/conf/${conf_file}": + ensure => present, + content => template("sunet/mariadb/backup/${conf_file}.erb"), + mode => '0744', + } + } + file { '/opt/mariadb/backup/start_replica_from_init.sh': + ensure => present, + content => template('sunet/mariadb/backup/start_replica_from_init.erb.sh'), + mode => '0744', + } + # XXX trigger needed + file { '/opt/mariadb/backup/do_backup.sh': + ensure => present, + content => template('sunet/mariadb/backup/do_backup.erb.sh'), + mode => '0744', + } + + file { '/usr/local/bin/check_replication': + ensure => present, + content => template('sunet/mariadb/backup/check_replication.erb'), + mode => '0744', + } + file { '/usr/local/bin/status-test': + ensure => present, + content => template('sunet/mariadb/backup/status-test.erb'), + mode => '0744', + } + file { '/etc/sudoers.d/99-status-test': + ensure => file, + content => "script ALL=(root) NOPASSWD: /usr/local/bin/status-test\n", + mode => '0440', + owner => 'root', + group => 'root', + } + sunet::docker_compose { 'mariadb_backup': + content => template('sunet/mariadb/docker-compose_mariadb.yml.erb'), + service_name => 'mariadb_backup', + compose_dir => '/opt/', + compose_filename => 'docker-compose.yml', + description => 'Mariadb replica', + } + +} diff --git a/templates/mariadb/backup/check_replication.erb b/templates/mariadb/backup/check_replication.erb new file mode 100755 index 000000000..0672c60e0 --- /dev/null +++ b/templates/mariadb/backup/check_replication.erb @@ -0,0 +1,10 @@ +#!/bin/bash + +result="$(docker exec mariadb_backup_mariadb_backup_1 mysql -p<%= @mariadb_root_password %> -BN -e 'show status like "slave_running"')" +if [[ "${result}" == "Slave_running ON" ]]; then + echo "OK: Replica running" + exit 0 +else + echo "CRITICAL: Replica not running" + exit 2 +fi diff --git a/templates/mariadb/backup/do_backup.erb.sh b/templates/mariadb/backup/do_backup.erb.sh new file mode 100644 index 000000000..bc1d43861 --- /dev/null +++ b/templates/mariadb/backup/do_backup.erb.sh @@ -0,0 +1,12 @@ +#!/bin/bash +stream_name="mariadb-stream-$(date +%Y-%m-%dT%H.%M.%S).gz" +dump_name="mariadb-dump-$(date +%Y-%m-%dT%H.%M.%S).sql.gz" +backup_dir="/opt/mariadb/backups/$(date +%Y/%m/%d)" +mkdir -p "${backup_dir}" + +buopts="--slave-info --safe-slave-backup" +dumpopts="--dump-slave" +mysql -p"${MYSQL_ROOT_PASSWORD}" -e "stop slave" +mariadb-backup --backup ${buopts} -u root -p"${MYSQL_ROOT_PASSWORD}" --stream=xbstream | gzip >"${backup_dir}/${stream_name}" +mysqldump --all-databases --single-transaction ${dumpopts} -u root -p${MYSQL_ROOT_PASSWORD} | gzip >"${backup_dir}/${dump_name}" +mysql -p${MYSQL_ROOT_PASSWORD} -e "start slave" diff --git a/templates/mariadb/backup/start_replica_from_init.erb.sh b/templates/mariadb/backup/start_replica_from_init.erb.sh new file mode 100644 index 000000000..c41c12575 --- /dev/null +++ b/templates/mariadb/backup/start_replica_from_init.erb.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +mysql="mysql -u root -p${MYSQL_ROOT_PASSWORD}" +init_file='/backups/init.sql.gz' +if [[ -f ${init_file} ]]; then + ${mysql} -e "STOP SLAVE;RESET SLAVE;" + master_command=$(zgrep 'CHANGE MASTER TO MASTER_LOG_FILE' ${init_file} | sed -e 's/^-- //' -e 's/;$//') + master_command="${master_command}, MASTER_HOST='<%= @repliacte_from %>', MASTER_USER='backup'" + master_command="${master_command}, MASTER_PASSWORD='<%= @mariadb_backup_password%>', MASTER_SSL=1" + master_command="${master_command}, MASTER_CONNECT_RETRY=20" + zcat ${init_file} | ${mysql} + ${mysql} -e "${master_command}" + ${mysql} -e "START SLAVE" + sleep 3s + ${mysql} -e "SHOW SLAVE STATUS\G" +fi + +exit 0 diff --git a/templates/mariadb/backup/status-test.erb b/templates/mariadb/backup/status-test.erb new file mode 100644 index 000000000..197e50bc8 --- /dev/null +++ b/templates/mariadb/backup/status-test.erb @@ -0,0 +1,3 @@ +#!/bin/bash + +docker exec mariadb_backup_mariadb_backup_1 mysql -u root -p'<%= @mariadb_root_password %>' -N -B -e "show status like 'Slave_running'" diff --git a/templates/mariadb/docker-compose_mariadb.yml.erb b/templates/mariadb/docker-compose_mariadb.yml.erb index d92245767..22d635dc8 100644 --- a/templates/mariadb/docker-compose_mariadb.yml.erb +++ b/templates/mariadb/docker-compose_mariadb.yml.erb @@ -11,7 +11,12 @@ services: - /opt/mariadb/datadir:/var/lib/mysql - /opt/mariadb/init:/docker-entrypoint-initdb.d - /opt/mariadb/scripts:/scripts +<%- if @backup -%> + - /opt/mariadb_backup/start_replica_from_init.sh:/start_replica_from_init.sh +<% end -%> +<%- if @galera -%> network_mode: host +<% end -%> <%- if !@dns.empty? -%> dns: <% @dns.each do |resolver| -%> @@ -29,8 +34,10 @@ services: <%- if @mariadb_database -%> - MYSQL_DATABASE=<%= @mariadb_database %> <%- end -%> +<%- if @galera -%> - BOOTSTRAP=<%= @bootstrap %> - FORCE_BOOTSTRAP=0 command: "--wsrep_cluster_address=gcomm://<%= @cluster_nodes.join(',') %>" tty: true +<%- end -%> diff --git a/templates/mariadb/my.cnf.erb b/templates/mariadb/my.cnf.erb index 47556ed19..e80e89cb0 100644 --- a/templates/mariadb/my.cnf.erb +++ b/templates/mariadb/my.cnf.erb @@ -34,6 +34,7 @@ innodb_rollback_on_timeout = 1 innodb_write_io_threads = 4 # CPU dependent transaction_isolation = 'READ-COMMITTED' +<% if @galera -%> # Galera wsrep_cluster_name = "Sunet_MariaDB_Cluster" wsrep_gtid_domain_id = 1000 # same on all Galera nodes in the same segment @@ -45,3 +46,4 @@ wsrep_provider_options = "gcache.size=2G;gmcast.segment=0" # gmcast.seg wsrep_slave_threads = 4 # CPU dependent wsrep_sst_method = mariabackup wsrep_sync_wait = 1 +<% end -%> From 36598416a43eb9a03fa8c7794536f259a8de10d3 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Mon, 23 Sep 2024 14:36:20 +0200 Subject: [PATCH 02/32] Share config with cluster class --- manifests/mariadb/backup.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/mariadb/backup.pp b/manifests/mariadb/backup.pp index d532a6d57..3aaf52b53 100644 --- a/manifests/mariadb/backup.pp +++ b/manifests/mariadb/backup.pp @@ -32,7 +32,7 @@ $conf_files.each |$conf_file|{ file { "/opt/mariadb/backup/conf/${conf_file}": ensure => present, - content => template("sunet/mariadb/backup/${conf_file}.erb"), + content => template("sunet/mariadb/${conf_file}.erb"), mode => '0744', } } From bfa23cd320a6a400c37d1779863b057d9d7db72a Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Mon, 23 Sep 2024 14:40:03 +0200 Subject: [PATCH 03/32] Option to change resolvers inside container --- manifests/mariadb/backup.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/mariadb/backup.pp b/manifests/mariadb/backup.pp index 3aaf52b53..c20db9f15 100644 --- a/manifests/mariadb/backup.pp +++ b/manifests/mariadb/backup.pp @@ -2,6 +2,7 @@ class sunet::mariadb::backup( $tag_mariadb=undef, $location=undef + Array[String] $dns = [], ) { include sunet::packages::netcat_openbsd From b85cc51bfd85bedeac93d787079f3c2e2ed87d34 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Mon, 23 Sep 2024 14:40:24 +0200 Subject: [PATCH 04/32] Not in use outside Drive --- manifests/mariadb/backup.pp | 1 - 1 file changed, 1 deletion(-) diff --git a/manifests/mariadb/backup.pp b/manifests/mariadb/backup.pp index c20db9f15..ec94aab40 100644 --- a/manifests/mariadb/backup.pp +++ b/manifests/mariadb/backup.pp @@ -1,7 +1,6 @@ # This is a asyncronous replica of the Maria DB Cluster for SUNET class sunet::mariadb::backup( $tag_mariadb=undef, - $location=undef Array[String] $dns = [], ) { From 3379ff31e112a6a2f43394d189e7194dcdf222b9 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Mon, 23 Sep 2024 14:42:10 +0200 Subject: [PATCH 05/32] Use variable already in Compose file --- manifests/mariadb/backup.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/mariadb/backup.pp b/manifests/mariadb/backup.pp index ec94aab40..5ff9157e0 100644 --- a/manifests/mariadb/backup.pp +++ b/manifests/mariadb/backup.pp @@ -1,6 +1,6 @@ # This is a asyncronous replica of the Maria DB Cluster for SUNET class sunet::mariadb::backup( - $tag_mariadb=undef, + String $mariadb_version=latest, Array[String] $dns = [], ) { From 951875bfe4900535dd2fe654427836c8d14a5309 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Mon, 23 Sep 2024 14:43:59 +0200 Subject: [PATCH 06/32] Create basedir --- manifests/mariadb/backup.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/mariadb/backup.pp b/manifests/mariadb/backup.pp index 5ff9157e0..c37f39e51 100644 --- a/manifests/mariadb/backup.pp +++ b/manifests/mariadb/backup.pp @@ -5,6 +5,7 @@ ) { include sunet::packages::netcat_openbsd + ensure_resource('file',"/opt/mariadb/backup/", { ensure => directory, recurse => true } ) $dirs = [ 'datadir', 'init', 'conf', 'backups' ] $dirs.each | $dir | { ensure_resource('file',"/opt/mariadb/backup/${dir}", { ensure => directory, recurse => true } ) From 1d8d8ccc4ceda9a27594d886b0549b1b0e6cf520 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Mon, 23 Sep 2024 14:59:50 +0200 Subject: [PATCH 07/32] Run as a plain mariadb --- manifests/mariadb/backup.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/mariadb/backup.pp b/manifests/mariadb/backup.pp index c37f39e51..69b615ae2 100644 --- a/manifests/mariadb/backup.pp +++ b/manifests/mariadb/backup.pp @@ -66,9 +66,9 @@ owner => 'root', group => 'root', } - sunet::docker_compose { 'mariadb_backup': + sunet::docker_compose { 'mariadb': content => template('sunet/mariadb/docker-compose_mariadb.yml.erb'), - service_name => 'mariadb_backup', + service_name => 'mariadb', compose_dir => '/opt/', compose_filename => 'docker-compose.yml', description => 'Mariadb replica', From 2b0b80fce21d9c5d398cc9a70c3bc9ac7b0baebe Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Tue, 24 Sep 2024 09:47:54 +0200 Subject: [PATCH 08/32] Use the correct variable names --- manifests/mariadb/backup.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/mariadb/backup.pp b/manifests/mariadb/backup.pp index 69b615ae2..f2bd657d3 100644 --- a/manifests/mariadb/backup.pp +++ b/manifests/mariadb/backup.pp @@ -15,9 +15,9 @@ $replicate_from = cluster_nodes[0] # Secrets from local.eyaml - $mysql_root_password = safe_hiera('mariadb_root_password') - $backup_password = safe_hiera('mariadb_root_password') - $mysql_user_password = safe_hiera('mariadb_user_password') + $mariadb_root_password = safe_hiera('mariadb_root_password') + $mariadb_backup_password = safe_hiera('mariadb_root_password') + $mariadb_user_password = safe_hiera('mariadb_user_password') sunet::system_user {'mysql': username => 'mysql', group => 'mysql' } From 25bfdec6628901963db9e5365b6afe15e0589e84 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Thu, 26 Sep 2024 14:17:26 +0200 Subject: [PATCH 09/32] Put script in a location where it can be reached by container --- manifests/mariadb/backup.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/mariadb/backup.pp b/manifests/mariadb/backup.pp index f2bd657d3..136a6f952 100644 --- a/manifests/mariadb/backup.pp +++ b/manifests/mariadb/backup.pp @@ -37,7 +37,7 @@ mode => '0744', } } - file { '/opt/mariadb/backup/start_replica_from_init.sh': + file { '/opt/mariadb/scripts/start_replica_from_init.sh': ensure => present, content => template('sunet/mariadb/backup/start_replica_from_init.erb.sh'), mode => '0744', From 392e9f00ccba95b44d37ddb1430c7d9f0215b2a1 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Thu, 26 Sep 2024 14:30:45 +0200 Subject: [PATCH 10/32] Tyop --- templates/mariadb/backup/start_replica_from_init.erb.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/mariadb/backup/start_replica_from_init.erb.sh b/templates/mariadb/backup/start_replica_from_init.erb.sh index c41c12575..3f6242c34 100644 --- a/templates/mariadb/backup/start_replica_from_init.erb.sh +++ b/templates/mariadb/backup/start_replica_from_init.erb.sh @@ -4,7 +4,7 @@ init_file='/backups/init.sql.gz' if [[ -f ${init_file} ]]; then ${mysql} -e "STOP SLAVE;RESET SLAVE;" master_command=$(zgrep 'CHANGE MASTER TO MASTER_LOG_FILE' ${init_file} | sed -e 's/^-- //' -e 's/;$//') - master_command="${master_command}, MASTER_HOST='<%= @repliacte_from %>', MASTER_USER='backup'" + master_command="${master_command}, MASTER_HOST='<%= @replicate_from %>', MASTER_USER='backup'" master_command="${master_command}, MASTER_PASSWORD='<%= @mariadb_backup_password%>', MASTER_SSL=1" master_command="${master_command}, MASTER_CONNECT_RETRY=20" zcat ${init_file} | ${mysql} From 5df08a2596ca7827670d13a288e89e30f6011267 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Thu, 26 Sep 2024 14:38:00 +0200 Subject: [PATCH 11/32] Syntax error --- manifests/mariadb/backup.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/mariadb/backup.pp b/manifests/mariadb/backup.pp index 136a6f952..769568b51 100644 --- a/manifests/mariadb/backup.pp +++ b/manifests/mariadb/backup.pp @@ -12,7 +12,7 @@ } $cluster_nodes = lookup('mariadb_cluster_nodes', undef, undef,[]) - $replicate_from = cluster_nodes[0] + $replicate_from = $cluster_nodes[0] # Secrets from local.eyaml $mariadb_root_password = safe_hiera('mariadb_root_password') From ff21f32b0fe70b1fd9f5d336c500219acb91f284 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Thu, 26 Sep 2024 15:23:59 +0200 Subject: [PATCH 12/32] Put config where mariadb reads --- manifests/mariadb/backup.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/mariadb/backup.pp b/manifests/mariadb/backup.pp index 769568b51..2d38c461a 100644 --- a/manifests/mariadb/backup.pp +++ b/manifests/mariadb/backup.pp @@ -31,7 +31,7 @@ } $conf_files = ['credentials.cnf', 'my.cnf'] $conf_files.each |$conf_file|{ - file { "/opt/mariadb/backup/conf/${conf_file}": + file { "/opt/mariadb/conf/${conf_file}": ensure => present, content => template("sunet/mariadb/${conf_file}.erb"), mode => '0744', From 1a94c14322d3aa91a504dc558d83bde10ff2fa77 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Fri, 27 Sep 2024 10:05:38 +0200 Subject: [PATCH 13/32] server_id must be unique Previous method always returned 1001. --- manifests/mariadb.pp | 1 - templates/mariadb/my.cnf.erb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/manifests/mariadb.pp b/manifests/mariadb.pp index 1994e8f4f..490e6da46 100644 --- a/manifests/mariadb.pp +++ b/manifests/mariadb.pp @@ -17,7 +17,6 @@ $clients = lookup('mariadb_clients', undef, undef,['127.0.0.1']) $cluster_nodes = lookup('mariadb_cluster_nodes', undef, undef,[]) $mariadb_dir = '/opt/mariadb' - $server_id = 1000 + Integer($facts['networking']['hostname'][-1]) # Hack to not clash with docker_compose which tries to create the same directory exec {'mariadb_dir_create': diff --git a/templates/mariadb/my.cnf.erb b/templates/mariadb/my.cnf.erb index e80e89cb0..f64591e8c 100644 --- a/templates/mariadb/my.cnf.erb +++ b/templates/mariadb/my.cnf.erb @@ -18,7 +18,7 @@ gtid_ignore_duplicates = ON gtid_strict_mode = ON log_bin = binlog log_slave_updates = ON -server_id = <%= @server_id %> +server_id = <%= @facts['networking']['ip'].split(".").map(&:to_i).pack('CCCC').unpack('N')[0] %> # Innodb innodb_autoinc_lock_mode = 2 From 33b1b95f507facfa1efc461f135e1e04e7006018 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Fri, 27 Sep 2024 11:07:04 +0200 Subject: [PATCH 14/32] Static relay logs --- templates/mariadb/my.cnf.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/mariadb/my.cnf.erb b/templates/mariadb/my.cnf.erb index f64591e8c..a66cb4aa0 100644 --- a/templates/mariadb/my.cnf.erb +++ b/templates/mariadb/my.cnf.erb @@ -19,6 +19,8 @@ gtid_strict_mode = ON log_bin = binlog log_slave_updates = ON server_id = <%= @facts['networking']['ip'].split(".").map(&:to_i).pack('CCCC').unpack('N')[0] %> +# Default hostname base relay_log is no good in containers +relay_log = 'relay-log' # Innodb innodb_autoinc_lock_mode = 2 From 5fd3df4e35c113eb0ab29d15b173c79d75abb553 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Fri, 27 Sep 2024 11:07:56 +0200 Subject: [PATCH 15/32] Explain the witch craft --- templates/mariadb/my.cnf.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/mariadb/my.cnf.erb b/templates/mariadb/my.cnf.erb index a66cb4aa0..30c0664e6 100644 --- a/templates/mariadb/my.cnf.erb +++ b/templates/mariadb/my.cnf.erb @@ -18,6 +18,7 @@ gtid_ignore_duplicates = ON gtid_strict_mode = ON log_bin = binlog log_slave_updates = ON +# Use IP adress as decimal in order to create an unique server id server_id = <%= @facts['networking']['ip'].split(".").map(&:to_i).pack('CCCC').unpack('N')[0] %> # Default hostname base relay_log is no good in containers relay_log = 'relay-log' From ab3f51fb74ffee55d0ee6d9e925cd36656bb6887 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Fri, 27 Sep 2024 11:42:29 +0200 Subject: [PATCH 16/32] Match cluster class names --- templates/mariadb/backup/status-test.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/mariadb/backup/status-test.erb b/templates/mariadb/backup/status-test.erb index 197e50bc8..8094c9eff 100644 --- a/templates/mariadb/backup/status-test.erb +++ b/templates/mariadb/backup/status-test.erb @@ -1,3 +1,3 @@ #!/bin/bash -docker exec mariadb_backup_mariadb_backup_1 mysql -u root -p'<%= @mariadb_root_password %>' -N -B -e "show status like 'Slave_running'" +docker exec mariadb-db-1 mysql -u root -p'<%= @mariadb_root_password %>' -N -B -e "show status like 'Slave_running'" From d211ca2c84420478c4a28c3de60d2a10e35c1d08 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Fri, 27 Sep 2024 11:44:40 +0200 Subject: [PATCH 17/32] Match cluster names --- templates/mariadb/backup/check_replication.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/mariadb/backup/check_replication.erb b/templates/mariadb/backup/check_replication.erb index 0672c60e0..035dc4a6d 100755 --- a/templates/mariadb/backup/check_replication.erb +++ b/templates/mariadb/backup/check_replication.erb @@ -1,6 +1,6 @@ #!/bin/bash -result="$(docker exec mariadb_backup_mariadb_backup_1 mysql -p<%= @mariadb_root_password %> -BN -e 'show status like "slave_running"')" +result="$(docker exec mariadb-db-1 mysql -p<%= @mariadb_root_password %> -BN -e 'show status like "slave_running"')" if [[ "${result}" == "Slave_running ON" ]]; then echo "OK: Replica running" exit 0 From 955662dc67ce199ed58a1dfe2968c28787826759 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Fri, 27 Sep 2024 11:49:05 +0200 Subject: [PATCH 18/32] Allow container access --- manifests/mariadb/backup.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/mariadb/backup.pp b/manifests/mariadb/backup.pp index 2d38c461a..3cb3105b2 100644 --- a/manifests/mariadb/backup.pp +++ b/manifests/mariadb/backup.pp @@ -43,7 +43,7 @@ mode => '0744', } # XXX trigger needed - file { '/opt/mariadb/backup/do_backup.sh': + file { '/opt/mariadb/scripts/do_backup.sh': ensure => present, content => template('sunet/mariadb/backup/do_backup.erb.sh'), mode => '0744', From b9cc800eadadb64f416f28d4df06428b613fb107 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Fri, 27 Sep 2024 11:51:20 +0200 Subject: [PATCH 19/32] Run inside container --- templates/mariadb/backup/do_backup.erb.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/mariadb/backup/do_backup.erb.sh b/templates/mariadb/backup/do_backup.erb.sh index bc1d43861..67a77d04a 100644 --- a/templates/mariadb/backup/do_backup.erb.sh +++ b/templates/mariadb/backup/do_backup.erb.sh @@ -1,7 +1,7 @@ #!/bin/bash stream_name="mariadb-stream-$(date +%Y-%m-%dT%H.%M.%S).gz" dump_name="mariadb-dump-$(date +%Y-%m-%dT%H.%M.%S).sql.gz" -backup_dir="/opt/mariadb/backups/$(date +%Y/%m/%d)" +backup_dir="/backups/$(date +%Y/%m/%d)" mkdir -p "${backup_dir}" buopts="--slave-info --safe-slave-backup" From e12f9ff2815b6f0a39fd1ef5c3cd839de509fde7 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Fri, 27 Sep 2024 12:15:56 +0200 Subject: [PATCH 20/32] Allow NRPE to check the replication --- manifests/mariadb/backup.pp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/manifests/mariadb/backup.pp b/manifests/mariadb/backup.pp index 3cb3105b2..1c707e3ff 100644 --- a/manifests/mariadb/backup.pp +++ b/manifests/mariadb/backup.pp @@ -2,6 +2,7 @@ class sunet::mariadb::backup( String $mariadb_version=latest, Array[String] $dns = [], + Boolean $nrpe = true; ) { include sunet::packages::netcat_openbsd @@ -66,6 +67,14 @@ owner => 'root', group => 'root', } + sunet::sudoer {'nagios_run_replication_command': + user_name => 'nagios', + collection => 'nrpe_replication_check', + command_line => '/usr/local/bin/check_replication' + } + sunet::nagios::nrpe_command {'check_async_replication': + command_line => '/usr/bin/sudo /usr/local/bin/check_replication' + } sunet::docker_compose { 'mariadb': content => template('sunet/mariadb/docker-compose_mariadb.yml.erb'), service_name => 'mariadb', From 28ffc385acaabf7d4df60d716122973c1b08f41d Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Fri, 27 Sep 2024 12:17:47 +0200 Subject: [PATCH 21/32] This is not perl :( --- manifests/mariadb/backup.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/mariadb/backup.pp b/manifests/mariadb/backup.pp index 1c707e3ff..fd5e1eab6 100644 --- a/manifests/mariadb/backup.pp +++ b/manifests/mariadb/backup.pp @@ -2,7 +2,7 @@ class sunet::mariadb::backup( String $mariadb_version=latest, Array[String] $dns = [], - Boolean $nrpe = true; + Boolean $nrpe = true, ) { include sunet::packages::netcat_openbsd From 72129eef624988ad97a79d6212278882bde44820 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Fri, 27 Sep 2024 12:18:02 +0200 Subject: [PATCH 22/32] Wrap in feature flag --- manifests/mariadb/backup.pp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/manifests/mariadb/backup.pp b/manifests/mariadb/backup.pp index fd5e1eab6..e8cb36d0f 100644 --- a/manifests/mariadb/backup.pp +++ b/manifests/mariadb/backup.pp @@ -67,13 +67,16 @@ owner => 'root', group => 'root', } - sunet::sudoer {'nagios_run_replication_command': - user_name => 'nagios', - collection => 'nrpe_replication_check', - command_line => '/usr/local/bin/check_replication' - } - sunet::nagios::nrpe_command {'check_async_replication': - command_line => '/usr/bin/sudo /usr/local/bin/check_replication' + + if $nrpe { + sunet::sudoer {'nagios_run_replication_command': + user_name => 'nagios', + collection => 'nrpe_replication_check', + command_line => '/usr/local/bin/check_replication' + } + sunet::nagios::nrpe_command {'check_async_replication': + command_line => '/usr/bin/sudo /usr/local/bin/check_replication' + } } sunet::docker_compose { 'mariadb': content => template('sunet/mariadb/docker-compose_mariadb.yml.erb'), From 0ac72ce850fa7dd4a8d812b81ada9be54ee06669 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Fri, 27 Sep 2024 13:12:19 +0200 Subject: [PATCH 23/32] Don't reinvent the wheel - use a define! --- manifests/mariadb/backup.pp | 34 ++++------------------------------ 1 file changed, 4 insertions(+), 30 deletions(-) diff --git a/manifests/mariadb/backup.pp b/manifests/mariadb/backup.pp index e8cb36d0f..14743686a 100644 --- a/manifests/mariadb/backup.pp +++ b/manifests/mariadb/backup.pp @@ -5,11 +5,10 @@ Boolean $nrpe = true, ) { - include sunet::packages::netcat_openbsd - ensure_resource('file',"/opt/mariadb/backup/", { ensure => directory, recurse => true } ) - $dirs = [ 'datadir', 'init', 'conf', 'backups' ] - $dirs.each | $dir | { - ensure_resource('file',"/opt/mariadb/backup/${dir}", { ensure => directory, recurse => true } ) + sunet::mariadb { 'sunet_mariadb_simple': + mariadb_version => $mariadb_version, + ports => [3306], + dns => $dns, } $cluster_nodes = lookup('mariadb_cluster_nodes', undef, undef,[]) @@ -20,24 +19,6 @@ $mariadb_backup_password = safe_hiera('mariadb_root_password') $mariadb_user_password = safe_hiera('mariadb_user_password') - sunet::system_user {'mysql': username => 'mysql', group => 'mysql' } - - $sql_files = ['02-backup_user.sql'] - $sql_files.each |$sql_file|{ - file { "/opt/mariadb/backup/init/${sql_file}": - ensure => present, - content => template("sunet/mariadb/${sql_file}.erb"), - mode => '0744', - } - } - $conf_files = ['credentials.cnf', 'my.cnf'] - $conf_files.each |$conf_file|{ - file { "/opt/mariadb/conf/${conf_file}": - ensure => present, - content => template("sunet/mariadb/${conf_file}.erb"), - mode => '0744', - } - } file { '/opt/mariadb/scripts/start_replica_from_init.sh': ensure => present, content => template('sunet/mariadb/backup/start_replica_from_init.erb.sh'), @@ -78,12 +59,5 @@ command_line => '/usr/bin/sudo /usr/local/bin/check_replication' } } - sunet::docker_compose { 'mariadb': - content => template('sunet/mariadb/docker-compose_mariadb.yml.erb'), - service_name => 'mariadb', - compose_dir => '/opt/', - compose_filename => 'docker-compose.yml', - description => 'Mariadb replica', - } } From 6bbf78e9db156c63a5de2a63861792b3a04f3ad2 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Fri, 27 Sep 2024 13:14:14 +0200 Subject: [PATCH 24/32] Options --- manifests/mariadb.pp | 3 +-- manifests/mariadb/backup.pp | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/mariadb.pp b/manifests/mariadb.pp index 490e6da46..69fb91bbc 100644 --- a/manifests/mariadb.pp +++ b/manifests/mariadb.pp @@ -4,11 +4,10 @@ Integer $bootstrap=0, Array[Integer] $ports = [3306, 4444, 4567, 4568], Array[String] $dns = [], + Boolean $galera = true, ) { - $galera = true - $mariadb_root_password = lookup('mariadb_root_password', undef, undef,'NOT_SET_IN_HIERA') $mariadb_user = lookup('mariadb_user', undef, undef,undef) $mariadb_user_password = lookup('mariadb_user_password', undef, undef,undef) diff --git a/manifests/mariadb/backup.pp b/manifests/mariadb/backup.pp index 14743686a..f7cb7c35c 100644 --- a/manifests/mariadb/backup.pp +++ b/manifests/mariadb/backup.pp @@ -9,6 +9,7 @@ mariadb_version => $mariadb_version, ports => [3306], dns => $dns, + galera => False, } $cluster_nodes = lookup('mariadb_cluster_nodes', undef, undef,[]) From 177ade7ac5688869fdb8d4549fb4bf8993154b01 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Fri, 27 Sep 2024 13:15:06 +0200 Subject: [PATCH 25/32] Syntax error --- manifests/mariadb/backup.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/mariadb/backup.pp b/manifests/mariadb/backup.pp index f7cb7c35c..dd1f37fa2 100644 --- a/manifests/mariadb/backup.pp +++ b/manifests/mariadb/backup.pp @@ -9,7 +9,7 @@ mariadb_version => $mariadb_version, ports => [3306], dns => $dns, - galera => False, + galera => false, } $cluster_nodes = lookup('mariadb_cluster_nodes', undef, undef,[]) From 5d9c7c829cebd6fb105d9e4975bf7cb0d0a28493 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Fri, 27 Sep 2024 13:18:09 +0200 Subject: [PATCH 26/32] Don't clash with the backup files --- manifests/mariadb.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/mariadb.pp b/manifests/mariadb.pp index 69fb91bbc..d82cf336a 100644 --- a/manifests/mariadb.pp +++ b/manifests/mariadb.pp @@ -65,14 +65,14 @@ content => template('sunet/mariadb/cluster-status.erb.sh'), mode => '0744', } - file { '/etc/sudoers.d/99-size-test': + file { '/etc/sudoers.d/99-cluster-size-test': ensure => file, content => "script ALL=(root) NOPASSWD: /usr/local/bin/cluster-size\n", mode => '0440', owner => 'root', group => 'root', } - file { '/etc/sudoers.d/99-status-test': + file { '/etc/sudoers.d/99-cluster-status-test': ensure => file, content => "script ALL=(root) NOPASSWD: /usr/local/bin/cluster-status\n", mode => '0440', From dbfd2d8ec32129753ab3d8568ea39a99f9e41158 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Fri, 27 Sep 2024 14:09:01 +0200 Subject: [PATCH 27/32] Start doing the backup --- manifests/mariadb/backup.pp | 15 ++++++++++++++- templates/mariadb/backup/backup2baas.erb | 11 +++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100755 templates/mariadb/backup/backup2baas.erb diff --git a/manifests/mariadb/backup.pp b/manifests/mariadb/backup.pp index dd1f37fa2..ac6f8beaa 100644 --- a/manifests/mariadb/backup.pp +++ b/manifests/mariadb/backup.pp @@ -25,13 +25,26 @@ content => template('sunet/mariadb/backup/start_replica_from_init.erb.sh'), mode => '0744', } - # XXX trigger needed file { '/opt/mariadb/scripts/do_backup.sh': ensure => present, content => template('sunet/mariadb/backup/do_backup.erb.sh'), mode => '0744', } + file { '/usr/local/bin/backup2baas': + ensure => present, + content => template('sunet/mariadb/backup/backup2baas.erb'), + mode => '0744', + } + + sunet::scriptherder::cronjob { 'backup2baas': + cmd => '/usr/local/bin/backup2baas', + hour => '6', + minute => '0', + ok_criteria => ['exit_status=0', 'max_age=24h'], + warn_criteria => ['exit_status=1'], + } + file { '/usr/local/bin/check_replication': ensure => present, content => template('sunet/mariadb/backup/check_replication.erb'), diff --git a/templates/mariadb/backup/backup2baas.erb b/templates/mariadb/backup/backup2baas.erb new file mode 100755 index 000000000..69a4dc757 --- /dev/null +++ b/templates/mariadb/backup/backup2baas.erb @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -e + +docker exec mariadb-db-1 /scripts/do_backup.sh + +BACKUPDIR=/opt/mariadb/backups +find "${BACKUPDIR}" -type f -mtime +31 -exec rm -f {} \; +find "${BACKUPDIR}" -empty -type d -delete + +/usr/bin/dsmc backup From db7f7ff75634b29b4e249fc7b0bcd15cbe3e4ace Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Fri, 27 Sep 2024 14:20:24 +0200 Subject: [PATCH 28/32] Don't run at the same time as binlog purge --- manifests/mariadb/backup.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/mariadb/backup.pp b/manifests/mariadb/backup.pp index ac6f8beaa..61849c2d5 100644 --- a/manifests/mariadb/backup.pp +++ b/manifests/mariadb/backup.pp @@ -40,7 +40,7 @@ sunet::scriptherder::cronjob { 'backup2baas': cmd => '/usr/local/bin/backup2baas', hour => '6', - minute => '0', + minute => '10', ok_criteria => ['exit_status=0', 'max_age=24h'], warn_criteria => ['exit_status=1'], } From 1f02d5552d1a03bcef2c98b599aa42606cbe5c89 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Mon, 7 Oct 2024 09:27:43 +0200 Subject: [PATCH 29/32] Make baas2 optional --- manifests/mariadb/backup.pp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/manifests/mariadb/backup.pp b/manifests/mariadb/backup.pp index 61849c2d5..2e06f9243 100644 --- a/manifests/mariadb/backup.pp +++ b/manifests/mariadb/backup.pp @@ -2,6 +2,7 @@ class sunet::mariadb::backup( String $mariadb_version=latest, Array[String] $dns = [], + Boolean $backup_to_baas = true, Boolean $nrpe = true, ) { @@ -31,18 +32,20 @@ mode => '0744', } - file { '/usr/local/bin/backup2baas': - ensure => present, - content => template('sunet/mariadb/backup/backup2baas.erb'), - mode => '0744', - } + if $backup_to_baas { + file { '/usr/local/bin/backup2baas': + ensure => present, + content => template('sunet/mariadb/backup/backup2baas.erb'), + mode => '0744', + } - sunet::scriptherder::cronjob { 'backup2baas': - cmd => '/usr/local/bin/backup2baas', - hour => '6', - minute => '10', - ok_criteria => ['exit_status=0', 'max_age=24h'], - warn_criteria => ['exit_status=1'], + sunet::scriptherder::cronjob { 'backup2baas': + cmd => '/usr/local/bin/backup2baas', + hour => '6', + minute => '10', + ok_criteria => ['exit_status=0', 'max_age=24h'], + warn_criteria => ['exit_status=1'], + } } file { '/usr/local/bin/check_replication': From a252059d58f77d300a217fd833f2a8ccc3e47309 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Mon, 7 Oct 2024 10:12:39 +0200 Subject: [PATCH 30/32] Better explain what script does Also less risk for name collitions --- manifests/mariadb.pp | 8 ++++---- manifests/mariadb/backup.pp | 14 +++++++------- .../{status-test.erb => replication-status.erb} | 0 3 files changed, 11 insertions(+), 11 deletions(-) rename templates/mariadb/backup/{status-test.erb => replication-status.erb} (100%) diff --git a/manifests/mariadb.pp b/manifests/mariadb.pp index d82cf336a..dd3e509d4 100644 --- a/manifests/mariadb.pp +++ b/manifests/mariadb.pp @@ -55,26 +55,26 @@ ok_criteria => ['exit_status=0','max_age=2d'], warn_criteria => ['exit_status=1','max_age=3d'], } - file { '/usr/local/bin/cluster-size': + file { '/usr/local/bin/mariadb-galera-size': ensure => present, content => template('sunet/mariadb/cluster-size.erb.sh'), mode => '0744', } - file { '/usr/local/bin/cluster-status': + file { '/usr/local/bin/mariadb-galera-status': ensure => present, content => template('sunet/mariadb/cluster-status.erb.sh'), mode => '0744', } file { '/etc/sudoers.d/99-cluster-size-test': ensure => file, - content => "script ALL=(root) NOPASSWD: /usr/local/bin/cluster-size\n", + content => "script ALL=(root) NOPASSWD: /usr/local/bin/mariadb-galera-size\n", mode => '0440', owner => 'root', group => 'root', } file { '/etc/sudoers.d/99-cluster-status-test': ensure => file, - content => "script ALL=(root) NOPASSWD: /usr/local/bin/cluster-status\n", + content => "script ALL=(root) NOPASSWD: /usr/local/bin/mariadb-galera-status\n", mode => '0440', owner => 'root', group => 'root', diff --git a/manifests/mariadb/backup.pp b/manifests/mariadb/backup.pp index 2e06f9243..c8ecf67fa 100644 --- a/manifests/mariadb/backup.pp +++ b/manifests/mariadb/backup.pp @@ -48,19 +48,19 @@ } } - file { '/usr/local/bin/check_replication': + file { '/usr/lib/nagios/plugins/check_mariadb-replication': ensure => present, content => template('sunet/mariadb/backup/check_replication.erb'), mode => '0744', } - file { '/usr/local/bin/status-test': + file { '/usr/local/bin/mariadb-replication-status': ensure => present, - content => template('sunet/mariadb/backup/status-test.erb'), + content => template('sunet/mariadb/backup/replication-status.erb'), mode => '0744', } - file { '/etc/sudoers.d/99-status-test': + file { '/etc/sudoers.d/99-mariadb-replication-test': ensure => file, - content => "script ALL=(root) NOPASSWD: /usr/local/bin/status-test\n", + content => "script ALL=(root) NOPASSWD: /usr/local/bin/mariadb-replication-status", mode => '0440', owner => 'root', group => 'root', @@ -70,10 +70,10 @@ sunet::sudoer {'nagios_run_replication_command': user_name => 'nagios', collection => 'nrpe_replication_check', - command_line => '/usr/local/bin/check_replication' + command_line => '/usr/lib/nagios/plugins/check_mariadb-replication' } sunet::nagios::nrpe_command {'check_async_replication': - command_line => '/usr/bin/sudo /usr/local/bin/check_replication' + command_line => '/usr/bin/sudo /usr/lib/nagios/plugins/check_mariadb-replication' } } diff --git a/templates/mariadb/backup/status-test.erb b/templates/mariadb/backup/replication-status.erb similarity index 100% rename from templates/mariadb/backup/status-test.erb rename to templates/mariadb/backup/replication-status.erb From 19b4fde5f91464c8d926f76b13135c2e44e3b001 Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Mon, 7 Oct 2024 10:26:29 +0200 Subject: [PATCH 31/32] Less duplicated data --- templates/mariadb/backup/check_replication.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/mariadb/backup/check_replication.erb b/templates/mariadb/backup/check_replication.erb index 035dc4a6d..d8ca60ff2 100755 --- a/templates/mariadb/backup/check_replication.erb +++ b/templates/mariadb/backup/check_replication.erb @@ -1,6 +1,6 @@ #!/bin/bash -result="$(docker exec mariadb-db-1 mysql -p<%= @mariadb_root_password %> -BN -e 'show status like "slave_running"')" +result="$(/usr/local/bin/mariadb-replication-status)" if [[ "${result}" == "Slave_running ON" ]]; then echo "OK: Replica running" exit 0 From 13bde2cc94ef8c339ba4c62c4a5a54570c08c90f Mon Sep 17 00:00:00 2001 From: Johan Wassberg Date: Mon, 7 Oct 2024 12:07:24 +0200 Subject: [PATCH 32/32] Simplifiy integer calculation --- lib/puppet/functions/ipv4_to_int.rb | 12 ++++++++++++ manifests/mariadb.pp | 2 ++ templates/mariadb/my.cnf.erb | 3 +-- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 lib/puppet/functions/ipv4_to_int.rb diff --git a/lib/puppet/functions/ipv4_to_int.rb b/lib/puppet/functions/ipv4_to_int.rb new file mode 100644 index 000000000..055d0f0c6 --- /dev/null +++ b/lib/puppet/functions/ipv4_to_int.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + + +# Convert a single IPv4 address to an int + +require 'ipaddr' + +Puppet::Functions.create_function(:ipv4_to_int) do + def ipv4_to_int(*arguments) + IPAddr.new(arguments[0]).to_i + end +end diff --git a/manifests/mariadb.pp b/manifests/mariadb.pp index dd3e509d4..77426cbf3 100644 --- a/manifests/mariadb.pp +++ b/manifests/mariadb.pp @@ -93,6 +93,8 @@ content => template('sunet/mariadb/credentials.cnf.erb'), mode => '0744', } + + $server_id = ipv4_to_int($facts['networking']['ip']) file { "${mariadb_dir}/conf/my.cnf": ensure => present, content => template('sunet/mariadb/my.cnf.erb'), diff --git a/templates/mariadb/my.cnf.erb b/templates/mariadb/my.cnf.erb index 30c0664e6..be2d4015d 100644 --- a/templates/mariadb/my.cnf.erb +++ b/templates/mariadb/my.cnf.erb @@ -18,8 +18,7 @@ gtid_ignore_duplicates = ON gtid_strict_mode = ON log_bin = binlog log_slave_updates = ON -# Use IP adress as decimal in order to create an unique server id -server_id = <%= @facts['networking']['ip'].split(".").map(&:to_i).pack('CCCC').unpack('N')[0] %> +server_id = <%= @server_id %> # Default hostname base relay_log is no good in containers relay_log = 'relay-log'