Browse Source

Add RedHat support

0.1.x
Georg Vogetseder 3 years ago
parent
commit
1fd641b6ab

files/server/percona-server.logrotate → files/server/percona-server.logrotate.Debian View File


+ 20
- 0
files/server/percona-server.logrotate.RedHat View File

@@ -0,0 +1,20 @@
### MANAGED BY PUPPET
# - I put everything in one block and added sharedscripts, so that mysql gets
# flush-logs'd only once.
# Else the binary logs would automatically increase by n times every day.
/var/log/mysql.log /var/log/mysql/*.log {
daily
rotate 30
missingok
#create 600 mysql mysql
compress
sharedscripts
postrotate
# just if mysqld is really running
if test -x /usr/bin/mysqladmin && \
/usr/bin/mysqladmin ping &>/dev/null
then
/usr/bin/mysqladmin flush-logs
fi
endscript
}

+ 40
- 26
manifests/garbd.pp View File

@@ -1,10 +1,14 @@
# Setup garbd

class percona::garbd(
$clustername,
$garbd_package = undef,
) {

class { '::percona::server::nodes' :
clustername => $clustername
clustername => $clustername,
}
require ::percona::params


$galera_nodes = regsubst(
@@ -15,41 +19,51 @@ class percona::garbd(
',$',
''
)
$package = pick($garbd_package, $::percona::garbd_package, 'percona-xtradb-cluster-garbd-3')

if ($galera_nodes and !empty($galera_nodes)) {
ensure_packages('percona-xtradb-cluster-garbd-3')
ensure_packages($package)

# work around having a buggy init script.
# with some luck they'll ship a systemd service for jessie at some point
service { 'garbd.service' :
ensure => running,
provider => systemd,
hasrestart => true,
status => '/etc/init.d/garbd status',
hasstatus => false,
start => '/bin/systemctl restart garbd.service',
require => File['/var/lib/galera'],
if $::percona::params::garbd_fix_systemd == true {
# work around having a buggy init script.
# with some luck they'll ship a systemd service for jessie at some point
service { $::percona::params::garbd_service :
ensure => running,
provider => systemd,
hasrestart => true,
status => '/etc/init.d/garbd status',
hasstatus => false,
start => '/bin/systemctl restart garbd.service',
require => File['/var/lib/galera'],
}
file_line { 'fix-garbd-init-script' :
path => '/etc/init.d/garbd',
line => 'exit $?',
match => '^exit 0',
notify => Exec['garbd-systemctl-daemon-reload'],
}
exec { 'garbd-systemctl-daemon-reload' :
path => $::path,
refreshonly => true,
command => 'systemctl daemon-reload',
}
}
else {
service{ $::percona::params::garbd_service :
ensure => running,
enable => true,
provider => systemd,
require => File['/var/lib/galera'],
}
}

file { '/etc/default/garbd' :
file { $::percona::params::garbd_params_location :
ensure => file,
owner => root,
group => root,
mode => '0644',
content => template('percona/garbd/defaults.erb'),
notify => Service['garbd.service'],
}

file_line { 'fix-garbd-init-script' :
path => '/etc/init.d/garbd',
line => 'exit $?',
match => '^exit 0',
notify => Exec['garbd-systemctl-daemon-reload'],
}
exec { 'garbd-systemctl-daemon-reload' :
path => $::path,
refreshonly => true,
command => 'systemctl daemon-reload',
notify => Service[$::percona::params::garbd_service],
}

file { '/var/lib/galera' :

+ 13
- 8
manifests/init.pp View File

@@ -49,10 +49,12 @@ class percona(
$clusterchk_password,
$sst_password,
$replication_password,
$bind_address = $::ipaddress,
$wsrep_node_address = $bind_address,
$bind_address = $::percona::params::bind_address,
$wsrep_node_address = $::percona::params::wsrep_node_address,
$mysql_options = {},
$mysql_package = 'percona-xtradb-cluster-56',
$garbd_package = $::percona::params::garbd_package,
$garbd_fix_systemd = $::percona::params::garbd_fix_systemd,
$mysql_package = $::percona::params::mysql_package,
$haproxy_global_options = {},
$haproxy_defaults_options = {},
$haproxy_backend_options = {},
@@ -60,7 +62,9 @@ class percona(
$haproxy_readonly_frontend_bind = { "${wsrep_node_address}::3307" => [] },
$haproxy_readwrite_frontend_bind = { "${wsrep_node_address}::3308" => [] },
$haproxy_balancermember_options = 'check port 9200 inter 12000 rise 3 fall 3 weight 100',
) {
$buffersize = $::percona::params::buffersize,
$pool_instances = $::percona::params::pool_instances,
) inherits ::percona::params {


class { '::percona::server' :
@@ -78,9 +82,10 @@ class percona(

# clusterchk
class { '::percona::server::clustercheck' :
user => 'clusterchk',
password => $clusterchk_password,
require => Class['::percona::server'],
user => 'clusterchk',
password => $clusterchk_password,
mysqlconfig => $::percona::params::config_file,
require => Class['::percona::server'],
}

# haproxy
@@ -94,6 +99,6 @@ class percona(
haproxy_readonly_frontend_bind => $haproxy_readonly_frontend_bind,
haproxy_readwrite_frontend_bind => $haproxy_readwrite_frontend_bind,
haproxy_balancermember_options => $haproxy_balancermember_options,
require => Class['::percona::server::clustercheck']
require => Class['::percona::server::clustercheck'],
}
}

+ 34
- 0
manifests/params.pp View File

@@ -0,0 +1,34 @@
# The good, old params.pp pattern :)

class percona::params {
$bind_address = $::ipaddress
$wsrep_node_address = $::ipaddress
$buffersize = floor( $::memorysize_mb * 0.8 )
$pool_instances = ceiling( $buffersize / 1024 )

case $::osfamily {
'RedHat': {
$garbd_package = 'Percona-XtraDB-Cluster-garbd-3'
$mysql_package = 'Percona-XtraDB-Cluster-56'
$garbd_fix_systemd = false
$garbd_params_location = '/etc/sysconfig/garb'
$garbd_service = 'garb.service'
$config_file = '/etc/my.cnf'
$includedir = '/etc/my.cnf.d'
$wsrep_provider = '/usr/lib64/libgalera_smm.so'
}
'Debian': {
$garbd_package = 'percona-xtradb-cluster-garbd-3'
$mysql_package = 'percona-xtradb-cluster-56'
$garbd_fix_systemd = true
$garbd_params_location = '/etc/default/garbd'
$garbd_service = 'garbd.service'
$config_file = '/etc/mysql/my.cnf'
$includedir = '/etc/mysql/conf.d'
$wsrep_provider = '/usr/lib/libgalera_smm.so'
}
default: {
fail("${::osfamily} is not supported by ${::module_name}")
}
}
}

+ 36
- 25
manifests/server.pp View File

@@ -1,3 +1,5 @@
# Install Percona

class percona::server(
$clustername,
$root_password,
@@ -13,15 +15,16 @@ class percona::server(
$mysql_service_enable = false,
) {

require ::percona::params
require ::percona::server::config
$default_options = $::percona::server::config::default_options

::percona::server::nodes::export { $wsrep_node_address :
clustername => $clustername
clustername => $clustername,
}

class { '::percona::server::nodes' :
clustername => $clustername
clustername => $clustername,
}

$galera_nodes = regsubst(
@@ -34,14 +37,19 @@ class percona::server(
)

$server_default_options = {
'mysqld' => {
'bind-address' => $::ipaddress_eth0,
'mysqld' => {
'bind-address' => $bind_address,
'wsrep_node_address' => $wsrep_node_address,
'wsrep_cluster_address' => "gcomm://${galera_nodes}",
'wsrep_sst_auth' => "sst:${sst_password}",
'wsrep_cluster_name' => $clustername,
'wsrep_node_incoming_address' => $wsrep_node_address,
'wsrep_sst_receive_address' => $wsrep_node_address,
'pid-file' => '/var/run/mysqld/mysqld.pid',
'log-error' => '/var/log/mysql/error.log',
},
'mysqld-safe' => {
'log-error' => '/var/log/mysql/error.log',
},
}

@@ -51,7 +59,7 @@ class percona::server(
$mysql_options
)

class {'mysql::server' :
class {'::mysql::server' :
package_ensure => installed,
package_manage => true,
package_name => $mysql_package,
@@ -65,37 +73,40 @@ class percona::server(
remove_default_accounts => true,
root_password => $root_password,
override_options => $override_options,
config_file => $::percona::params::config_file,
includedir => $::percona::params::includedir,
}

file {'/etc/logrotate.d/percona-server':
ensure => file,
source => 'puppet:///modules/percona/server/percona-server.logrotate',
source => "puppet:///modules/percona/server/percona-server.logrotate.${::osfamily}",
}

file {'/etc/mysql/debian.cnf' :
ensure => file,
owner => 'root',
group => 'root',
mode => '0600',
require => Class['::mysql::server'],
content => template('percona/server/debian_cnf.erb'),
}
if $::osfamily == 'Debian' {
file {'/etc/mysql/debian.cnf' :
ensure => file,
owner => 'root',
group => 'root',
mode => '0600',
require => Class['::mysql::server'],
content => template('percona/server/debian_cnf.erb'),
}

mysql_user { 'debian-sys-maint@localhost':
ensure => 'present',
max_connections_per_hour => '0',
max_queries_per_hour => '0',
max_updates_per_hour => '0',
max_user_connections => '0',
password_hash => mysql_password($debian_password),
require => Class['::mysql::server'],
mysql_user { 'debian-sys-maint@localhost':
ensure => 'present',
max_connections_per_hour => '0',
max_queries_per_hour => '0',
max_updates_per_hour => '0',
max_user_connections => '0',
password_hash => mysql_password($debian_password),
require => Class['::mysql::server'],
}
}


mysql_user{ 'sst@localhost':
ensure => 'present',
password_hash => mysql_password($sst_password),
require => Class['mysql::server']
require => Class['mysql::server'],
}
mysql_grant { 'sst@localhost/*.*':
ensure => 'present',
@@ -103,7 +114,7 @@ class percona::server(
privileges => ['RELOAD', 'LOCK TABLES', 'REPLICATION CLIENT'],
table => '*.*',
user => 'sst@localhost',
require => Mysql_user['sst@localhost']
require => Mysql_user['sst@localhost'],
}

}

+ 4
- 3
manifests/server/config.pp View File

@@ -1,7 +1,8 @@
class percona::server::config {
require ::percona::params

$buffersize = floor( $::memorysize_mb * 0.8 )
$pool_instances = ceiling( $buffersize / 1024 )
$buffersize = $::percona::buffersize
$pool_instances = $::percona::pool_instances

$mysql_options = {
'mysqld' => {
@@ -62,7 +63,7 @@ class percona::server::config {
'datadir' => '/var/lib/mysql/data',
#'bind-address' => $::ipaddress_eth0,
#'wsrep_node_address' => $::ipaddress_eth0,
'wsrep_provider' => '/usr/lib/libgalera_smm.so',
'wsrep_provider' => $::percona::params::wsrep_provider,
#'wsrep_cluster_address' => "gcomm://${gcom_addresses}",
'wsrep_slave_threads' => ($::processorcount * 2),
'wsrep_sst_method' => 'xtrabackup-v2',

+ 5
- 3
manifests/server/haproxy.pp View File

@@ -10,7 +10,9 @@ class percona::server::haproxy(
$haproxy_balancermember_options = 'check port 9200 inter 12000 rise 3 fall 3 weight 100',
){

ensure_packages('hatop')
if $::osfamily == 'Debian' {
ensure_packages('hatop')
}

$clusternodes = getvar("::percona_cluster_${clustername}")
$clusternodes_array = split($clusternodes, ',')
@@ -106,8 +108,8 @@ class percona::server::haproxy(
::haproxy::backend{"${clustername}-ro": }
::haproxy::backend{"${clustername}-rw": }

Haproxy::Balancermember <<| listening_service == "${clustername}-ro" and tag == 'bzed-percona_cluster' |>>
Haproxy::Balancermember <<| listening_service == "${clustername}-rw" and tag == 'bzed-percona_cluster' |>>
Haproxy::Balancermember<<| listening_service == "${clustername}-ro" and tag == 'bzed-percona_cluster' |>>
Haproxy::Balancermember<<| listening_service == "${clustername}-rw" and tag == 'bzed-percona_cluster' |>>

@@::haproxy::balancermember{"${::hostname}-ro":
listening_service => "${clustername}-ro",

Loading…
Cancel
Save