commit dfd4eb224a057d60dd2f6f7a754f533afd32d36c Author: Eugene Kirpichov Date: Fri Sep 7 17:38:58 2012 -0700 Initial commit diff --git a/deployment/puppet/galera/README b/deployment/puppet/galera/README new file mode 100644 index 0000000000..e544ab313e --- /dev/null +++ b/deployment/puppet/galera/README @@ -0,0 +1,35 @@ +This is a good start to play around with the galera multi-master mysql synchronous replication (http://www.codership.com/products/mysql_galera) + +HOWTO: + + * play around (add a database and data, chaos-monkey nodes etc.) + + +WARNING + +Change the mysql root password in production and limit access to galera cluster members! + +TODO + + * naming: master -> donor + * put a load balancer in front of the cluster + * make cluster "masterless" + +nodes.pp + +# nodes +$cluster_name = 'wsrep_galera_cluster' + +node /mysql-db-01/ { + class { 'galera' : + cluster_name => $cluster_name + } +} + +node /mysql-db-0([2-9])/ { + $master_ip = '172.18.67.254' + class { 'galera' : + cluster_name => $cluster_name, + master_ip => $master_ip + } +} diff --git a/deployment/puppet/galera/files/galera-23.2.1-amd64.deb b/deployment/puppet/galera/files/galera-23.2.1-amd64.deb new file mode 100644 index 0000000000..fb7bfac9de Binary files /dev/null and b/deployment/puppet/galera/files/galera-23.2.1-amd64.deb differ diff --git a/deployment/puppet/galera/files/mysql-server-wsrep-5.5.23-23.6-amd64.deb b/deployment/puppet/galera/files/mysql-server-wsrep-5.5.23-23.6-amd64.deb new file mode 100644 index 0000000000..f229875651 Binary files /dev/null and b/deployment/puppet/galera/files/mysql-server-wsrep-5.5.23-23.6-amd64.deb differ diff --git a/deployment/puppet/galera/manifests/init.pp b/deployment/puppet/galera/manifests/init.pp new file mode 100644 index 0000000000..ca25c964c5 --- /dev/null +++ b/deployment/puppet/galera/manifests/init.pp @@ -0,0 +1,68 @@ +# +# wget https://launchpad.net/codership-mysql/5.5/5.5.23-23.6/+download/mysql-server-wsrep-5.5.23-23.6-amd64.deb +# wget https://launchpad.net/galera/2.x/23.2.1/+download/galera-23.2.1-amd64.deb +# aptitude install mysql-client libdbd-mysql-perl libdbi-perl +# aptitude install libssl0.9.8 +# dpkg -i mysql-server-wsrep-5.5.23-23.6-amd64.deb +# dpkg -i galera-23.2.1-amd64.deb +# vi /etc/mysql/conf.d/wsrep.cnf +# /etc/init.d/mysql start +# +class galera($cluster_name, $master_ip = false) { + + $mysql_user = "wsrep_sst" + $mysql_password = "password" + + service { "mysql-galera" : + name => "mysql", + ensure => "running", + require => [Package["mysql-server-wsrep", "galera"], File["/etc/mysql/conf.d/wsrep.cnf"]], + hasrestart => true, + # hasstatus => true, // http://projects.puppetlabs.com/issues/5610 + } + + package { ["mysql-client", "libssl0.9.8", "libaio1"] : + ensure => present, + } + + package { ["mysql-server-5.5", "mysql-server-core-5.5"] : + ensure => purged, + } + + package { "mysql-server-wsrep" : + ensure => present, + provider => "dpkg", + source => "/tmp/mysql-server-wsrep.deb", + require => [Package["mysql-server-5.5"], Package["mysql-server-core-5.5"], Package["libaio1"], File["/tmp/mysql-server-wsrep.deb"], Package["mysql-client"]], + } + + file { "/tmp/mysql-server-wsrep.deb" : + source => "puppet:///modules/galera/mysql-server-wsrep-5.5.23-23.6-amd64.deb" + } + + package { "galera" : + ensure => present, + provider => "dpkg", + source => "/tmp/galera.deb", + require => [File["/tmp/galera.deb"], Package["libssl0.9.8"]], + } + + file { "/tmp/galera.deb" : + source => "puppet:///modules/galera/galera-23.2.1-amd64.deb" + } + + file { "/etc/mysql/conf.d/wsrep.cnf" : + ensure => present, + content => template("galera/wsrep.cnf.erb"), + require => Package["mysql-server-wsrep", "galera"], + } + + exec { "set-mysql-password" : + unless => "/usr/bin/mysql -u${mysql_user} -p${mysql_password}", + command => "/usr/bin/mysql -uroot -e \"set wsrep_on='off'; delete from mysql.user where user=''; grant all on *.* to '${mysql_user}'@'%' identified by '${mysql_password}';flush privileges;\"", + require => Service["mysql-galera"], + subscribe => Service["mysql-galera"], + refreshonly => true, + } + +} diff --git a/deployment/puppet/galera/templates/wsrep.cnf.erb b/deployment/puppet/galera/templates/wsrep.cnf.erb new file mode 100644 index 0000000000..c61fca4104 --- /dev/null +++ b/deployment/puppet/galera/templates/wsrep.cnf.erb @@ -0,0 +1,129 @@ +# This file contains wsrep-related mysqld options. It should be included +# in the main MySQL configuration file. +# +# Options that need to be customized: +# - wsrep_provider +# - wsrep_cluster_address +# - wsrep_sst_auth +# The rest of defaults should work out of the box. + +## +## mysqld options _MANDATORY_ for correct opration of the cluster +## +[mysqld] + +# (This must be substituted by wsrep_format) +binlog_format=ROW + +# Currently only InnoDB storage engine is supported +default-storage-engine=innodb + +# to avoid issues with 'bulk mode inserts' using autoinc +innodb_autoinc_lock_mode=2 + +# This is a must for paralell applying +innodb_locks_unsafe_for_binlog=1 + +# Query Cache is not supported with wsrep +query_cache_size=0 +query_cache_type=0 + +# Override bind-address +# In some systems bind-address defaults to 127.0.0.1, and with mysqldump SST +# it will have (most likely) disastrous consequences on donor node +bind-address=0.0.0.0 + +## +## WSREP options +## + +# Full path to wsrep provider library or 'none' +wsrep_provider=/usr/lib/galera/libgalera_smm.so + +# Provider specific configuration options +#wsrep_provider_options= + +# Logical cluster name. Should be the same for all nodes. +wsrep_cluster_name="<%= cluster_name -%>" + +# Group communication system handle +<% if master_ip -%> +wsrep_cluster_address="gcomm://<%= master_ip %>:4567" +<% else -%> +wsrep_cluster_address="gcomm://" +<% end -%> + +# Human-readable node name (non-unique). Hostname by default. +#wsrep_node_name= + +# Base replication [:port] of the node. +# The values supplied will be used as defaults for state transfer receiving, +# listening ports and so on. Default: address of the first network interface. +#wsrep_node_address= + +# Address for incoming client connections. Autodetect by default. +#wsrep_node_incoming_address= + +# How many threads will process writesets from other nodes +wsrep_slave_threads=1 + +# DBUG options for wsrep provider +#wsrep_dbug_option + +# Generate fake primary keys for non-PK tables (required for multi-master +# and parallel applying operation) +wsrep_certify_nonPK=1 + +# Maximum number of rows in write set +wsrep_max_ws_rows=131072 + +# Maximum size of write set +wsrep_max_ws_size=1073741824 + +# to enable debug level logging, set this to 1 +wsrep_debug=0 + +# convert locking sessions into transactions +wsrep_convert_LOCK_to_trx=0 + +# how many times to retry deadlocked autocommits +wsrep_retry_autocommit=1 + +# change auto_increment_increment and auto_increment_offset automatically +wsrep_auto_increment_control=1 + +# retry autoinc insert, which failed for duplicate key error +wsrep_drupal_282555_workaround=0 + +# enable "strictly synchronous" semantics for read operations +wsrep_causal_reads=0 + +# Command to call when node status or cluster membership changes. +# Will be passed all or some of the following options: +# --status - new status of this node +# --uuid - UUID of the cluster +# --primary - whether the component is primary or not ("yes"/"no") +# --members - comma-separated list of members +# --index - index of this node in the list +wsrep_notify_cmd= + +## +## WSREP State Transfer options +## + +# State Snapshot Transfer method +wsrep_sst_method=mysqldump + +# Address on THIS node to receive SST at. DON'T SET IT TO DONOR ADDRESS!!! +# (SST method dependent. Defaults to the first IP of the first interface) +#wsrep_sst_receive_address=<%= ipaddress_eth1 %>:3306 + +# SST authentication string. This will be used to send SST to joining nodes. +# Depends on SST method. For mysqldump method it is root: +wsrep_sst_auth=<%= mysql_user %>:<%= mysql_password %> + +# Desired SST donor name. +#wsrep_sst_donor= + +# Protocol version to use +# wsrep_protocol_version=