Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xtradb cluster #20

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions manifests/cluster.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# == Class percona::params
#
# === Parameters:
#
# === Provided parameters:
#
# === Examples:
#
# ==== Setting global and default configuration options.
#
# === Todo:
#
# TODO: Document parameters
#
class percona::cluster {
if ( $percona::cluster ) {
$params = {
'mysqld/server_id' => $percona::cluster_index,
'mysqld/wsrep_cluster_address' => $percona::cluster_address,
'mysqld/wsrep_node_name' => $percona::cluster_node_name,
'mysqld/wsrep_cluster_name' => $percona::cluster_name,
'mysqld/wsrep_slave_threads' => $percona::cluster_slave_threads,
'mysqld/wsrep_sst_method' => $percona::cluster_sst_method,
'mysqld/wsrep_provider' => $percona::cluster_wsrep_provider,
'mysqld/wsrep_sst_auth' => "${percona::cluster_replication_user}:${percona::cluster_replication_password}",
'mysqld/innodb_autoinc_lock_mode' => '2',
}
}

# For checking the cluster's health
if $::percona::cluster {
file { '/etc/xinetd.d/mysqlchk':
source => "puppet:///modules/percona/xinetd.d/mysqlchk",
owner => 'root',
group => 'root',
mode => '0555',
}
}
}
8 changes: 8 additions & 0 deletions manifests/config/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@
$params_version = {}
}

# Cluster specifics.
if $params['cluster'] {
$params_cluster = $params['cluster']
} else {
$params_cluster = {}
}

# Special case. Only add this parameter if it has been set. We need to do
# this like this because we can not adjust the params hash after it has been
# defined.
Expand All @@ -99,6 +106,7 @@
$default_global,
$params_version,
$params_global,
$params_cluster,
$tempdir,
]

Expand Down
24 changes: 24 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@
$config_replace = $percona::params::config_replace,
$config_include_dir = $::percona::params::config_include_dir,
$server = $percona::params::server,
$cluster = $percona::params::cluster,
$cluster_index = $percona::params::cluster_index,
$cluster_address = $percona::params::cluster_address,
$cluster_node_name = $percona::params::cluster_node_name,
$cluster_name = $percona::params::cluster_name,
$cluster_replication_user = $percona::params::cluster_replication_user,
$cluster_replication_password = $percona::params::cluster_replication_password,
$cluster_slave_threads = $percona::params::cluster_slave_threads,
$cluster_sst_method = $percona::params::cluster_sst_method,
$cluster_wsrep_provider = $percona::params::cluster_wsrep_provider,
$service_enable = $percona::params::service_enable,
$service_ensure = $percona::params::service_ensure,
$service_name = $percona::params::service_name,
Expand Down Expand Up @@ -106,12 +116,24 @@
$config_file = $percona::params::config_file,

) inherits percona::params {
include percona::cluster

$config_includedir = $config_include_dir ? {
undef => $config_include_dir_default,
default => $config_include_dir,
}

if ( $cluster ) {
if ( !$server ) {
fail("Percona cluster without server!")
}
if ( !$cluster_index or !cluster_name or !$cluster_node_name ) {
fail("Percona cluster needs cluster_index (my.cnf:server_id), cluster_name (my.cnf:wsrep_cluster_name), and cluster_node_name (my.cnf:wsrep_node_name)!")
}
if ( !$cluster_replication_user or !$cluster_replication_password ) {
fail("Percona cluster needs cluster_replication_user and cluster_replication_password (my.cnf:wsrep_sst_auth=user:password)!")
}
}

## Translate settings in params in a hash.
$params = {
Expand All @@ -133,13 +155,15 @@
'xtrabackup/datadir' => $::percona::datadir,
'xtrabackup/target_dir' => $::percona::targetdir,
},
'cluster' => $::percona::cluster::params,
}

include percona::preinstall
include percona::install
include percona::config
include percona::service

Class['percona::cluster'] ->
Class['percona::preinstall'] ->
Class['percona::install'] ->
Class['percona::config'] ->
Expand Down
70 changes: 46 additions & 24 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,68 @@
class percona::install {
$server = $::percona::server
$client = $::percona::client
$cluster = $::percona::cluster
$percona_version = $::percona::percona_version

case $::operatingsystem {
/(?i:debian|ubuntu)/: {
$pkg_version = $percona_version
$pkg_client_default = "percona-server-client-${pkg_version}"
$pkg_server_default = "percona-server-server-${pkg_version}"

case $percona_version {
'5.1': {
$pkg_common_default = [
'percona-toolkit',
"percona-server-common"
]
}
if $cluster {
$pkg_client_default = "percona-xtradb-cluster-client-${pkg_version}"
$pkg_server_default = "percona-xtradb-cluster-server-${pkg_version}"
$pkg_common_default = [
'percona-toolkit',
"percona-xtradb-cluster-common-${pkg_version}",
]
}
else {
$pkg_client_default = "percona-server-client-${pkg_version}"
$pkg_server_default = "percona-server-server-${pkg_version}"

default: {
$pkg_common_default = [
'percona-toolkit',
"percona-server-common-${pkg_version}"
]
}
# Avoid dependency resolution on version change
$pkg_common_default = [
'percona-toolkit',
$percona_version ? {
'5.1' => 'percona-server-common',
default => "percona-server-common-${pkg_version}",
},
]
}
}

/(?i:redhat|centos)/: {
$pkg_version = regsubst($percona_version, '\.', '', 'G')

$pkg_client_default = "Percona-Server-client-${pkg_version}"
$pkg_server_default = "Percona-Server-server-${pkg_version}"
$pkg_common_default = [
"Percona-Server-shared-${pkg_version}",
'percona-toolkit'
]
if $cluster {
$pkg_client_default = "Percona-XtraDB-Cluster-client"
$pkg_server_default = "Percona-XtraDB-Cluster-server"
# The Percona-Compat packages break Cluster-shared.
if ( $::percona::pkg_compat == false ) {
$pkg_common_default = [
'percona-toolkit',
'Percona-XtraDB-Cluster-shared',
]
}
else {
$pkg_common_default = 'percona-toolkit'
}
}
else {
$pkg_client_default = "Percona-Server-client-${pkg_version}"
$pkg_server_default = "Percona-Server-server-${pkg_version}"
$pkg_common_default = [
"Percona-Server-shared-${pkg_version}",
'percona-toolkit',
]
}

# Installation of Percona's shared compatibility libraries
case $percona_version {
'5.5': {
$pkg_compat = $::percona::pkg_compat ? {
undef => 'Percona-Server-shared-compat',
default => $::percona::pkg_compat,
undef => 'Percona-Server-shared-compat',
false => '',
default => $::percona::pkg_compat,
}
}
default: {
Expand All @@ -60,6 +81,7 @@
fail('Operating system not supported yet.')
}
}
# fail("package is $pkg_compat")

$pkg_client = $::percona::pkg_client ? {
undef => $pkg_client_default,
Expand Down
16 changes: 15 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
# TODO: Document parameters
#
class percona::params (
$percona_version = '5.1',
$percona_version = '5.5',
$client = true,
$config_content = undef,
$config_dir_mode = '0750',
Expand All @@ -57,6 +57,15 @@
$service_ensure = 'running',
$service_name = 'mysql',
$service_restart = true,
$cluster = false,
$cluster_index = undef,
$cluster_address = 'gcomm://',
$cluster_node_name = $fqdn,
$cluster_name = undef,
$cluster_replication_user = undef,
$cluster_replication_password = undef,
$cluster_slave_threads = 2,
$cluster_sst_method = 'xtrabackup',
$daemon_group = 'mysql',
$daemon_user = 'mysql',
$tmpdir = undef,
Expand Down Expand Up @@ -107,4 +116,9 @@
fail('Operating system not supported yet.')
}
}

$cluster_wsrep_provider = $::hardwareisa ? {
'x86_64' => '/usr/lib64/libgalera_smm.so',
default => '/usr/lib/libgalera_smm.so',
}
}