Galera Cluster for MySQL is a true Multimaster Cluster based on synchronous replication. It is an easy-to-use, high-availability solution, which provides high system up-time, no data loss and very potential for future growth.
Setup Galera Cluster with puppet is simple and easy. The management becomes much simpler and easy to streamline the things, you can take what was once a complex to manage.
Let's learn and have fun together!
1. OlinData Webinar 2015 -
https://docs.google.com/a/olindata.com/presentation/d/1vlwtPNRGkaIvJN0olgwknyDvVha910yb4_bM5UfXE8
I/edit?usp=sharing
Manage Galera Cluster
with Puppet
Configuration management with puppet
2. OlinData Webinar 2015 -
https://docs.google.com/a/olindata.com/presentation/d/1vlwtPNRGkaIvJN0olgwknyDvVha910yb4_bM5UfXE8
I/edit?usp=sharing
Who am I?
• Krishna Prajapati, MySQL Engineer at Olindata
http://www.olindata.com/
3. OlinData Webinar 2015 -
https://docs.google.com/a/olindata.com/presentation/d/1vlwtPNRGkaIvJN0olgwknyDvVha910yb4_bM5UfXE8
I/edit?usp=sharing
Overview
• What is puppet (for those not aware)?
• What is Galera Cluster?
• Terminology
• Block Diagram/Feature
• MySQL Parameter for Galera
• Puppet Module for Galera
• Install Galera health check
• Haproxy
• wsrep status
• Questions
4. OlinData Webinar 2015 -
https://docs.google.com/a/olindata.com/presentation/d/1vlwtPNRGkaIvJN0olgwknyDvVha910yb4_bM5UfXE8
I/edit?usp=sharing
What is Puppet and why do we care?
• Configuration management software
- http://www.olindata.com/blog/2014/08/puppet-master-agent-setup
- http://olindata.com/blog/2015/03/setup-puppet-server-centos-70
• Scales very well (from 1 to 200k+ nodes)
• Multi-platform (windows, *nix, Mac OS, BSD)
• Commercially supported Open Source
• Infrastructure as code
5. OlinData Webinar 2015 -
https://docs.google.com/a/olindata.com/presentation/d/1vlwtPNRGkaIvJN0olgwknyDvVha910yb4_bM5UfXE8
I/edit?usp=sharing
What is Galera Cluster ?
• Galera is a synchronous multimaster database cluster
• Opensource
• Multi-platform (*nix)
• Consists of
- Percona
- MariaDB
- MySQL
• HA
8. OlinData Webinar 2015 -
https://docs.google.com/a/olindata.com/presentation/d/1vlwtPNRGkaIvJN0olgwknyDvVha910yb4_bM5UfXE8
I/edit?usp=sharing
Galera Features
• True Multi-master Read and write to any node at any time.
• Synchronous Replication No slave lag, no data is lost at node
crash.
• Tightly Coupled All nodes hold the same state. No diverged
data between nodes allowed.
• Multi-threaded Slave For better performance. For any
workload.
9. OlinData Webinar 2015 -
https://docs.google.com/a/olindata.com/presentation/d/1vlwtPNRGkaIvJN0olgwknyDvVha910yb4_bM5UfXE8
I/edit?usp=sharing
• No Master-Slave Failover Operations or Use of VIP.
• Hot Standby No downtime during failover (since there is no
failover).
• Automatic Node Provisioning No need to manually back up
the database and copy it to the new node.
• Supports InnoDB.
• Transparent to Applications Required no (or minimal)
changes) to the application.
• No Read and Write Splitting Needed.
10. OlinData Webinar 2015 -
https://docs.google.com/a/olindata.com/presentation/d/1vlwtPNRGkaIvJN0olgwknyDvVha910yb4_bM5UfXE8
I/edit?usp=sharing
[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
bind-address=0.0.0.0
MySQL Parameter for Galera
12. OlinData Webinar 2015 -
https://docs.google.com/a/olindata.com/presentation/d/1vlwtPNRGkaIvJN0olgwknyDvVha910yb4_bM5UfXE8
I/edit?usp=sharing
Install Galera using puppet module
class profile::mysql::base {
include mysql::client
# the base profile contains logic to choose either profile::apt or profile::yum
Class['profile::base'] ~> Package['mysql_client']
Class['profile::base'] ~> Package['percona-toolkit']
Class['profile::base'] ~> Package['mysql-server']
Exec['apt_update'] -> Package['mysql_client'] -> Package['mysql-server']
# load the mysql options from hiera and pass them to mysql::server
$override_options = hiera_hash('profile::mysql::base::override_options', undef)
if $override_options {
class { 'mysql::server':
override_options => $override_options,
require => [Package['mysql_client']]
}
} else {
# we don't use default options, so error if nothing is found
fail('No hash found in hiera to override default mysql settings in class profile::mysql::base.')
13. OlinData Webinar 2015 -
https://docs.google.com/a/olindata.com/presentation/d/1vlwtPNRGkaIvJN0olgwknyDvVha910yb4_bM5UfXE8
I/edit?usp=sharing
# make sure percona toolkit and xtrabackup are present
package { 'percona-toolkit': ensure => latest, }
package { 'xtrabackup':
ensure => latest,
require => Class['profile::apt'],
}
}
From hiera
mysql::client::package_name: 'percona-xtradb-cluster-client-5.6'
mysql::server::package_name: 'percona-xtradb-cluster-server-5.6'
14. OlinData Webinar 2015 -
https://docs.google.com/a/olindata.com/presentation/d/1vlwtPNRGkaIvJN0olgwknyDvVha910yb4_bM5UfXE8
I/edit?usp=sharing
Install galera health check
class profile::mysql::galera {
include profile::mysql::base
include ::galera
include galera::health_check
# load haproxy frontends
$balancermembers = hiera_hash('profile::mysql::galera::balancermembers', undef)
if $balancermembers {
create_resources('@@haproxy::balancermember', $balancermembers)
}
}
15. OlinData Webinar 2015 -
https://docs.google.com/a/olindata.com/presentation/d/1vlwtPNRGkaIvJN0olgwknyDvVha910yb4_bM5UfXE8
I/edit?usp=sharing
health check
root@db01:~# clustercheck
HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 43
<html><body>MySQL is running.</body></html>
root@db01:~#
16. OlinData Webinar 2015 -
https://docs.google.com/a/olindata.com/presentation/d/1vlwtPNRGkaIvJN0olgwknyDvVha910yb4_bM5UfXE8
I/edit?usp=sharing
Install haproxy module
class profile::haproxy::galera {
include ::haproxy
# Make sure the wheezy backports repo is present before attempting the package
if $::lsbdistcodename == 'wheezy' {
Apt::Source['wheezy-backports'] -> Package['haproxy']
}
# load haproxy frontends
$listens = hiera_hash('profile::haproxy::galera::listen', undef)
if $listens {
create_resources('haproxy::listen', $listens)
} else {
fail('No listen settings found in hiera in class profile::haproxy::galera.')
}
}
17. OlinData Webinar 2015 -
https://docs.google.com/a/olindata.com/presentation/d/1vlwtPNRGkaIvJN0olgwknyDvVha910yb4_bM5UfXE8
I/edit?usp=sharing
Roles
class role::db::galera inherits role {
include profile::mysql::galera
}
class role::db::galeramaster inherits role::db::galera {
include profile::haproxy::galera
}
20. OlinData Webinar 2015 -
https://docs.google.com/a/olindata.com/presentation/d/1vlwtPNRGkaIvJN0olgwknyDvVha910yb4_bM5UfXE8
I/edit?usp=sharing
node 'master.olindata.vm' {
# this server is a puppetmaster
include role::master
}
node 'galera000.olindata.vm' {
# this server will be a galera node, also having an haProxy instance
include role::db::galeramaster
}
node /^galerad{3}.olindata.vm$/ {
# all other nodes are galera nodes
include role::db::galera
}
21. OlinData Webinar 2015 -
https://docs.google.com/a/olindata.com/presentation/d/1vlwtPNRGkaIvJN0olgwknyDvVha910yb4_bM5UfXE8
I/edit?usp=sharing
• Other mysql flavours like MariaDB, Percona can be installed
with the existing module
class { '::mysql::server':
package_ensure => 'present',
package_name => 'mariadb-server',
}
Galera Flavour Install
22. OlinData Webinar 2015 -
https://docs.google.com/a/olindata.com/presentation/d/1vlwtPNRGkaIvJN0olgwknyDvVha910yb4_bM5UfXE8
I/edit?usp=sharing
Upcoming training
http://olindata.com/training/upcoming
Puppet Fundamentals Training, Manila – April 2015
Monday, April 6, 2015 - 09:00
Philippines
Puppet
Puppet Fundamentals Training, Hyderabad – April 2015
Wednesday, April 15, 2015 - 09:00
India
Puppet
Puppet Fundamentals Training, Jakarta – April 2015
Monday, April 20, 2015 - 09:00
Indonesia
Puppet
Puppet Fundamentals Training, Vienna – April 2015
Monday, April 27, 2015 - 09:00
Austria
24. OlinData Webinar 2015 -
https://docs.google.com/a/olindata.com/presentation/d/1vlwtPNRGkaIvJN0olgwknyDvVha910yb4_bM5UfXE8
I/edit?usp=sharing
We’re hiring!
EU and Asia based
trainers
jobs@olindata.com