From 59dfda6ed38fce274c6100fa1587b0cf879626c4 Mon Sep 17 00:00:00 2001 From: Jay Janssen Date: Wed, 25 Apr 2012 09:42:49 -0400 Subject: [PATCH 01/11] changed to xtrabackup SST method default user is root --- modules/percona/templates/cluster/my.cnf.erb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/percona/templates/cluster/my.cnf.erb b/modules/percona/templates/cluster/my.cnf.erb index 9bb1690..08a472a 100644 --- a/modules/percona/templates/cluster/my.cnf.erb +++ b/modules/percona/templates/cluster/my.cnf.erb @@ -9,7 +9,8 @@ wsrep_sst_receive_address=<%= ipaddress_eth1 %> wsrep_node_incoming_address=<%= ipaddress_eth1 %> wsrep_slave_threads=2 wsrep_cluster_name=trimethylxanthine -wsrep_sst_method=rsync +#wsrep_sst_method=rsync +wsrep_sst_method=xtrabackup wsrep_node_name=<%= hostname %> innodb_locks_unsafe_for_binlog=1 innodb_autoinc_lock_mode=2 @@ -17,4 +18,5 @@ innodb_log_file_size=64M bind-address=<%= ipaddress_eth1 %> [mysql] +user=root prompt="<%=hostname %> mysql> " From 17a0eee32e7a5ed7508a3360d664a0f3a800d318 Mon Sep 17 00:00:00 2001 From: Jay Janssen Date: Wed, 25 Apr 2012 09:43:04 -0400 Subject: [PATCH 02/11] ignore .vagrant --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8000dd9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vagrant From 14a4db9e4ddd248ae16ff84a4b2eca6e351a65dc Mon Sep 17 00:00:00 2001 From: Jay Janssen Date: Wed, 25 Apr 2012 09:46:57 -0400 Subject: [PATCH 03/11] change control port so it doesn't conflict with SST on percona1 --- modules/galera/manifests/glb/service.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/galera/manifests/glb/service.pp b/modules/galera/manifests/glb/service.pp index 08e931f..d392dc4 100644 --- a/modules/galera/manifests/glb/service.pp +++ b/modules/galera/manifests/glb/service.pp @@ -2,7 +2,7 @@ exec { "run_glb": - command => "glbd --daemon --threads $glb_threads --control $glb_ip_control:4444 $glb_ip_loadbalancer:3306 $glb_list_backend", + command => "glbd --daemon --threads $glb_threads --control $glb_ip_control:4445 $glb_ip_loadbalancer:3306 $glb_list_backend", path => ["/usr/sbin", "/bin" ], require => Class['Galera::Glb::Packages'], unless => "ps ax | grep [g]lbd 2> /dev/null", From 57d3f1421e0ae23ed094462fdf7652cd04df4bfd Mon Sep 17 00:00:00 2001 From: Jay Janssen Date: Wed, 25 Apr 2012 09:54:03 -0400 Subject: [PATCH 04/11] Be sure to set wsrep_provider on percona1 as well as the others so it can recover if it needs to reclone from the cluster --- modules/percona/manifests/cluster/config.pp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/percona/manifests/cluster/config.pp b/modules/percona/manifests/cluster/config.pp index c6f2826..3463094 100644 --- a/modules/percona/manifests/cluster/config.pp +++ b/modules/percona/manifests/cluster/config.pp @@ -1,8 +1,10 @@ class percona::cluster::config { if $hostname == "percona1" { - $joinip = " " + # Percona1 can't join itself, so if this node gets wacked out, it tries to talk to percona2 + $joinip = "192.168.70.3" } else { + # All other nodes join percona1 $joinip = "192.168.70.2" } file { From 3916ea33a281bd75bb1622a60419cc8894ca584f Mon Sep 17 00:00:00 2001 From: Jay Janssen Date: Thu, 26 Apr 2012 14:41:34 -0400 Subject: [PATCH 05/11] revert explicit joinip for percona1 -- this is necessary for the cluster to start --- modules/percona/manifests/cluster/config.pp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/percona/manifests/cluster/config.pp b/modules/percona/manifests/cluster/config.pp index 3463094..9dcba3c 100644 --- a/modules/percona/manifests/cluster/config.pp +++ b/modules/percona/manifests/cluster/config.pp @@ -2,7 +2,8 @@ if $hostname == "percona1" { # Percona1 can't join itself, so if this node gets wacked out, it tries to talk to percona2 - $joinip = "192.168.70.3" + # $joinip = "192.168.70.3" + $joinip = " " } else { # All other nodes join percona1 $joinip = "192.168.70.2" From f6153bbff269a509bb1540852198966b27e42af0 Mon Sep 17 00:00:00 2001 From: Jay Janssen Date: Wed, 16 May 2012 15:59:48 -0400 Subject: [PATCH 06/11] Replaced wsrep_cluster_address with wsrep_urls --- modules/percona/templates/cluster/my.cnf.erb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/percona/templates/cluster/my.cnf.erb b/modules/percona/templates/cluster/my.cnf.erb index 08a472a..8dc2d61 100644 --- a/modules/percona/templates/cluster/my.cnf.erb +++ b/modules/percona/templates/cluster/my.cnf.erb @@ -1,10 +1,12 @@ +[mysqld_safe] +wsrep_urls=gcomm://192.168.70.2:4567,gcomm://192.168.70.3:4567,gcomm://192.168.70.4:4567,gcomm:// + [mysqld] datadir=/var/lib/mysql user=mysql log_error=error.log binlog_format=ROW wsrep_provider=/usr/lib64/libgalera_smm.so -wsrep_cluster_address=gcomm://<%= joinip %> wsrep_sst_receive_address=<%= ipaddress_eth1 %> wsrep_node_incoming_address=<%= ipaddress_eth1 %> wsrep_slave_threads=2 From be822fc4a31653b1f0e2bbe40316f878db763d77 Mon Sep 17 00:00:00 2001 From: Jay Janssen Date: Thu, 17 May 2012 10:46:27 -0400 Subject: [PATCH 07/11] Added xinet module to start up xinetd and use a correct mysqlchk --- modules/xinet/files/mysqlchk | 19 +++++++++++++++++++ modules/xinet/manifests/config.pp | 16 ++++++++++++++++ modules/xinet/manifests/init.pp | 9 +++++++++ modules/xinet/manifests/packages.pp | 5 +++++ modules/xinet/manifests/service.pp | 8 ++++++++ 5 files changed, 57 insertions(+) create mode 100644 modules/xinet/files/mysqlchk create mode 100644 modules/xinet/manifests/config.pp create mode 100644 modules/xinet/manifests/init.pp create mode 100644 modules/xinet/manifests/packages.pp create mode 100644 modules/xinet/manifests/service.pp diff --git a/modules/xinet/files/mysqlchk b/modules/xinet/files/mysqlchk new file mode 100644 index 0000000..8b7af88 --- /dev/null +++ b/modules/xinet/files/mysqlchk @@ -0,0 +1,19 @@ +# default: on +# description: mysqlchk +service mysqlchk +{ +# this is a config for xinetd, place it in /etc/xinetd.d/ + disable = no + type = UNLISTED + flags = REUSE + socket_type = stream + port = 9200 + wait = no + user = nobody + server = /usr/bin/clustercheck + log_on_failure += USERID + only_from = 192.168.70.0/24 + # recommended to put the IPs that need + # to connect exclusively (security purposes) + per_source = UNLIMITED +} \ No newline at end of file diff --git a/modules/xinet/manifests/config.pp b/modules/xinet/manifests/config.pp new file mode 100644 index 0000000..d58a91d --- /dev/null +++ b/modules/xinet/manifests/config.pp @@ -0,0 +1,16 @@ +class xinet::config { + file { + "/etc/xinetd.d/mysqlchk": + ensure => present, + owner => root, group => root, + require => [Class['xinet::packages'], Class['percona::cluster::config']], + source => "/vagrant/modules/xinet/files/mysqlchk"; + } + + mysql::rights { "clustercheck": + user => "clustercheckuser", + password => "clustercheckpassword!", + database => "mysql", + priv => ["process_priv"] + } +} \ No newline at end of file diff --git a/modules/xinet/manifests/init.pp b/modules/xinet/manifests/init.pp new file mode 100644 index 0000000..dd8b651 --- /dev/null +++ b/modules/xinet/manifests/init.pp @@ -0,0 +1,9 @@ +class xinet { + + include xinet::packages + include xinet::config + include xinet::service + + Class['xinet::packages'] -> Class['xinet::config'] -> Class['xinet::service'] + +} diff --git a/modules/xinet/manifests/packages.pp b/modules/xinet/manifests/packages.pp new file mode 100644 index 0000000..8098cc2 --- /dev/null +++ b/modules/xinet/manifests/packages.pp @@ -0,0 +1,5 @@ +class xinet::packages { + package { + "xinetd": ensure => installed; + } +} \ No newline at end of file diff --git a/modules/xinet/manifests/service.pp b/modules/xinet/manifests/service.pp new file mode 100644 index 0000000..f99b235 --- /dev/null +++ b/modules/xinet/manifests/service.pp @@ -0,0 +1,8 @@ +class xinet::service { + service { + "xinetd": + ensure => 'running', + require => Class['xinet::packages'], + subscribe => File['/etc/xinetd.d/mysqlchk']; + } +} From de2674ed61f9fd707f298a0859a21bcdc8e7e1f2 Mon Sep 17 00:00:00 2001 From: Jay Janssen Date: Thu, 17 May 2012 10:47:20 -0400 Subject: [PATCH 08/11] Added haproxy module at monitors mysql on all the cluster nodes over the xinetd service --- modules/haproxy/files/xtradb_cluster.cfg | 32 ++++++++++++++++++++++++ modules/haproxy/manifests/config.pp | 8 ++++++ modules/haproxy/manifests/init.pp | 9 +++++++ modules/haproxy/manifests/packages.pp | 6 +++++ modules/haproxy/manifests/service.pp | 10 ++++++++ 5 files changed, 65 insertions(+) create mode 100644 modules/haproxy/files/xtradb_cluster.cfg create mode 100644 modules/haproxy/manifests/config.pp create mode 100644 modules/haproxy/manifests/init.pp create mode 100644 modules/haproxy/manifests/packages.pp create mode 100644 modules/haproxy/manifests/service.pp diff --git a/modules/haproxy/files/xtradb_cluster.cfg b/modules/haproxy/files/xtradb_cluster.cfg new file mode 100644 index 0000000..d9e5cdd --- /dev/null +++ b/modules/haproxy/files/xtradb_cluster.cfg @@ -0,0 +1,32 @@ +# this config needs haproxy-1.4.20 + +global + log 127.0.0.1 local0 + log 127.0.0.1 local1 notice + maxconn 4096 + uid 99 + gid 99 + daemon + # debug + #quiet + +defaults + log global + mode http + option tcplog + option dontlognull + retries 3 + redispatch + maxconn 2000 + contimeout 5000 + clitimeout 50000 + srvtimeout 50000 + +listen mysql-cluster 0.0.0.0:4306 + mode tcp + balance roundrobin + option httpchk + + server percona1 192.168.70.2:3306 check port 9200 inter 12000 rise 3 fall 3 + server percona2 192.168.70.3:3306 check port 9200 inter 12000 rise 3 fall 3 + server percona3 192.168.70.4:3306 check port 9200 inter 12000 rise 3 fall 3 diff --git a/modules/haproxy/manifests/config.pp b/modules/haproxy/manifests/config.pp new file mode 100644 index 0000000..c741594 --- /dev/null +++ b/modules/haproxy/manifests/config.pp @@ -0,0 +1,8 @@ +class haproxy::config { + file { + "/etc/haproxy/haproxy.cfg": + ensure => present, + require => Class['haproxy::packages'], + source => "/vagrant/modules/haproxy/files/xtradb_cluster.cfg"; + } +} \ No newline at end of file diff --git a/modules/haproxy/manifests/init.pp b/modules/haproxy/manifests/init.pp new file mode 100644 index 0000000..3f44021 --- /dev/null +++ b/modules/haproxy/manifests/init.pp @@ -0,0 +1,9 @@ +class haproxy { + + include haproxy::packages + include haproxy::config + include haproxy::service + + Class['haproxy::packages'] -> Class['haproxy::config'] -> Class['haproxy::service'] + +} diff --git a/modules/haproxy/manifests/packages.pp b/modules/haproxy/manifests/packages.pp new file mode 100644 index 0000000..56b6f77 --- /dev/null +++ b/modules/haproxy/manifests/packages.pp @@ -0,0 +1,6 @@ +class haproxy::packages { + package { + "haproxy": ensure => installed; + } +} + diff --git a/modules/haproxy/manifests/service.pp b/modules/haproxy/manifests/service.pp new file mode 100644 index 0000000..257171b --- /dev/null +++ b/modules/haproxy/manifests/service.pp @@ -0,0 +1,10 @@ +class haproxy::service { + + service { + "haproxy": + ensure => 'running', + require => Class['haproxy::config'], + subscribe => File['/etc/haproxy/haproxy.cfg'] + } + +} \ No newline at end of file From 74809e001a8021647d389a9a776f9a4f930c3ac9 Mon Sep 17 00:00:00 2001 From: Jay Janssen Date: Thu, 17 May 2012 10:48:09 -0400 Subject: [PATCH 09/11] Added xinet to all hosts, haproxy to percona1, removed glbd --- manifests/site.pp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/manifests/site.pp b/manifests/site.pp index f77717b..f0d942b 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -1,19 +1,19 @@ node percona1 { include percona::repository include percona::cluster + include xinet include myhosts + include haproxy + + Class['percona::repository'] -> Class['percona::cluster'] - Class['percona::repository'] -> Class['percona::cluster'] -> Class['galera::glb'] - class { - 'galera::glb': - glb_list_backend => "192.168.70.2:3306:1 192.168.70.3:3306:1 192.168.70.4:3306" - } } node percona2 { include percona::repository include percona::cluster + include xinet include myhosts Class['percona::repository'] -> Class['percona::cluster'] @@ -23,6 +23,7 @@ node percona3 { include percona::repository include percona::cluster + include xinet include myhosts Class['percona::repository'] -> Class['percona::cluster'] From 7deb713a23659f338d88eec3db86047bbce24473 Mon Sep 17 00:00:00 2001 From: Jay Janssen Date: Thu, 24 May 2012 13:10:55 -0400 Subject: [PATCH 10/11] add percona toolkit to all installs, fixed toolkit package to rely on the yum repo --- manifests/site.pp | 8 +++++++- modules/percona/manifests/toolkit.pp | 10 ++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/manifests/site.pp b/manifests/site.pp index f0d942b..51f2b15 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -1,31 +1,37 @@ node percona1 { include percona::repository include percona::cluster + include percona::toolkit include xinet include myhosts include haproxy Class['percona::repository'] -> Class['percona::cluster'] - + Class['percona::repository'] -> Class['percona::toolkit'] } node percona2 { include percona::repository include percona::cluster + include percona::toolkit include xinet include myhosts Class['percona::repository'] -> Class['percona::cluster'] + Class['percona::repository'] -> Class['percona::toolkit'] } node percona3 { include percona::repository include percona::cluster + include percona::toolkit include xinet include myhosts Class['percona::repository'] -> Class['percona::cluster'] + Class['percona::repository'] -> Class['percona::toolkit'] + } diff --git a/modules/percona/manifests/toolkit.pp b/modules/percona/manifests/toolkit.pp index f23dc23..3455a86 100644 --- a/modules/percona/manifests/toolkit.pp +++ b/modules/percona/manifests/toolkit.pp @@ -8,10 +8,8 @@ "perl-DBD-MySQL": ensure => installed, require => Package['Percona-Server-shared-compat']; - "percona-toolkit": - provider => rpm, - ensure => installed, - require => [ Package['perl-Time-HiRes'], Package['perl-TermReadKey'], Package['perl-DBD-MySQL'] ], - source => "http://www.percona.com/redir/downloads/percona-toolkit/percona-toolkit-1.0.1-1.noarch.rpm"; - } + "percona-toolkit": + ensure => installed, + require => [ Package['perl-Time-HiRes'], Package['perl-TermReadKey'], Package['perl-DBD-MySQL'] ]; + } } From 3ea7875d9b19b2d64cfedc6780b1da674791ebd3 Mon Sep 17 00:00:00 2001 From: Jay Janssen Date: Thu, 24 May 2012 13:16:44 -0400 Subject: [PATCH 11/11] Added a failover only writer proxy into the HA proxy config, setup a stats page for HA proxy and updated the readme. --- Readme | 7 ++++-- modules/haproxy/files/xtradb_cluster.cfg | 27 ++++++++++++++++++------ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Readme b/Readme index bb98abe..fd4e585 100644 --- a/Readme +++ b/Readme @@ -15,9 +15,12 @@ vagrant up percona3 And this is all, you have now 3 servers running Percona XtraDB Cluster ! -These recipes also install GLB (Galera Load Balancer) on percona1. +These recipes also install HAProxy on percona1. One for writes (single cluster node) and one for reads (rr of all cluster nodes). -You can read more on shinguz's post : http://www.fromdual.com/mysql-and-galera-load-balancer +See cluster status: http://192.168.70.2:9999/ + +Writes: 192.168.70.2:4306 +Reads: 192.168.70.2:5306 Note: SElinux is disabled, there is a selinux policy file included that allows the server to start but the other nodes aren't yet able to sync, I need to investigate... diff --git a/modules/haproxy/files/xtradb_cluster.cfg b/modules/haproxy/files/xtradb_cluster.cfg index d9e5cdd..54437df 100644 --- a/modules/haproxy/files/xtradb_cluster.cfg +++ b/modules/haproxy/files/xtradb_cluster.cfg @@ -1,4 +1,4 @@ -# this config needs haproxy-1.4.20 +# this config needs haproxy-1.4.19 global log 127.0.0.1 local0 @@ -16,17 +16,32 @@ defaults option tcplog option dontlognull retries 3 - redispatch + option redispatch maxconn 2000 contimeout 5000 clitimeout 50000 srvtimeout 50000 -listen mysql-cluster 0.0.0.0:4306 +listen cluster-writes 0.0.0.0:4306 mode tcp balance roundrobin option httpchk - server percona1 192.168.70.2:3306 check port 9200 inter 12000 rise 3 fall 3 - server percona2 192.168.70.3:3306 check port 9200 inter 12000 rise 3 fall 3 - server percona3 192.168.70.4:3306 check port 9200 inter 12000 rise 3 fall 3 + server percona1 192.168.70.2:3306 check port 9200 inter 12000 rise 3 fall 3 backup + server percona2 192.168.70.3:3306 check port 9200 inter 12000 rise 3 fall 3 backup + server percona3 192.168.70.4:3306 check port 9200 inter 12000 rise 3 fall 3 backup + +listen cluster-reads 0.0.0.0:5306 + mode tcp + balance roundrobin + option httpchk + + server percona1 192.168.70.2:3306 check port 9200 inter 12000 rise 3 fall 3 + server percona2 192.168.70.3:3306 check port 9200 inter 12000 rise 3 fall 3 + server percona3 192.168.70.4:3306 check port 9200 inter 12000 rise 3 fall 3 + + +listen admin_page 0.0.0.0:9999 + mode http + balance roundrobin + stats uri / \ No newline at end of file