G a l e r a C l u s t e r
Seppo Jaakola
Codership
2
www.codership.com
Agenda
● The Meaning of Galera
● Galera Cluster Short Introduction
● Migrating to Galera Cluster
● Galera Project
● MariaDB Galera Cluster 5.5.29 GA
3
www.codership.com
What is the Meaning of Galera ?
Turns out it has different semantics in:
● Italy
● Uruguay
● Brazil
● Spain, Portugal, Russia...
4
www.codership.com
Galera in Italy
Che cosa significa la parola galera?
5
www.codership.com
Galera in Italy
Che cosa significa la parola galera?
Jail / Prison
6
www.codership.com
Galera in Italy
Che cosa significa la parola galera?
Poliziotto
Jail / Prison
7
www.codership.com
Otto Poliziotto ?
8
www.codership.com
Galera in Uruguay
Que significa galera en Uruguai?
9
www.codership.com
Galera in Uruguay
Que significaca galera en Uruguai?
Traditional tall hat
10
www.codership.com
Galera in Brazil
Como sobre em Brazil?
11
www.codership.com
Galera in Brazil
A Group of Happy People
12
www.codership.com
Galera in Spain, Portugal, Russia...
Here's the correct meaning for Galera...
13
www.codership.com
Galera in Spain, Portugal, Russia...
Galley
Galera Cluster
15
www.codership.com
MariaDB
Multi-Master Replication
Galera Replication
16
www.codership.com
MariaDB MariaDB
Multi-Master Replication
Galera Replication
There can be several nodes
17
www.codership.com
MariaDB MariaDB MariaDB
Multi-Master Replication
Galera Replication
There can be several nodes
18
www.codership.com
MariaDB MariaDB MariaDB
Multi-Master Replication
Galera Replication
Client can connect to any node
There can be several nodes
19
www.codership.com
MariaDB MariaDB MariaDB
Multi-Master Replication
Galera Replication
Client can connect to any node
There can be several nodes
read & write read & write read & write Read & write access to any node
20
www.codership.com
MariaDB MariaDB MariaDB
Multi-Master Replication
Galera Replication
Replication is synchronous
read & write read & write read & write
Client can connect to any node
There can be several nodes
Read & write access to any node
21
www.codership.com
MariaDB
Multi-Master Replication
a
Multi-master cluster looks
like one big database with
multiple entry points
read & write read & write read & write
22
www.codership.com
MariaDB MariaDB MariaDB
Synchronous Replication
a
Galera Replication
Read & write
Transaction is
processed locally up
to commit time
23
www.codership.com
MariaDB MariaDB MariaDB
Synchronous Replication
Galera Replication
commit
Transaction's write
set is replicated to
whole cluster
Slave queueSlave queue
24
www.codership.com
Galera Replication
MariaDB MariaDB MariaDB
Synchronous Replication
OK
Client gets OK
status
Slave queueSlave queue
25
www.codership.com
Galera Replication
MariaDB MariaDB MariaDB
Synchronous Replication
Transaction is
applied in slaves
Slave queueSlave queue
26
www.codership.com
MariaDB MariaDB MariaDB
How node failures are handled
a
Galera Replication
Load Balancing
27
www.codership.com
MariaDB MariaDB MariaDB
Quorum
a
Galera Replication
Load Balancing
● Galera uses quorum based
failure handling:
– When cluster partitioning is
detected, the majority
partition "has quorum" and
can continue
– A minority partition cannot
commit transactions, but will
attempt to re-connect to
primary partition
– Note: 50% is not majority!
=> Minimum 3 nodes
recommended.
● Load balancer will notice errors
& remove node from pool
Optimistic Concurrency Control
29
www.codership.com
Galera Replication
A
Optimistic Concurrency Control
commit
Trx A
B
commit
Trx B
30
www.codership.com
Galera Replication
A
Optimistic Concurrency Control
commit
Trx A
B
commit
Trx B
DEADLOCK
eror
ROLLBACK
31
www.codership.com
Optimistic Concurrency Control
● Transactions process independently
in each cluster node
● Transaction write sets will be
replicated at commit time (before
commit)
● Cluster wide conflicts will be resolved
and conflict victim must rollback
Optimistic Concurrency Control
32
www.codership.com
Multi-Master or Not
● If your application can handle deadlock
errors, multi-master is good to use
● However, if database has hot-spots, i.e.
multi-master conflicts happen frequently,
write performance will suffer
● But read scalability is always guaranteed
● Use Master-Slave, if deadlock errors are a
problem or conflict rate hurts your
performance
Parallel Replication
34
www.codership.com
MariaDB
Parallel Replication
Slave queue
Slave thd Slave thd
Any number of slave applier
threads can be started
Slave control
35
www.codership.com
MariaDB
Parallel Replication
Slave queue
Slave thd Slave thd
Any number of slave applier
threads can be started
Slave control assigns write
sets for slave appliers
Slave control
36
www.codership.com
MariaDB
Parallel Replication
Slave queue
Slave thd Slave thd
Any number of slave applier
threads can be started
Slave control assigns write
sets for slave appliers
Slave control is on ROW levelSlave control
38
www.codership.com
MariaDB
Parallel Replication
Slave queue
Slave thd Slave thd
Slave control
Any number of slave applier
threads can be started
Slave control assigns write
sets for slave appliers
Slave control is on ROW level
Only applying is parallel
commit order is dictated
39
www.codership.com
Parallel Applying
● Aka parallel replication
● Every application will benefit of it, because it
works:
● not on database
● not on table
● but on row level
● wsrep_slave_threads=n
● How many slaves makes sense:
● Monitor wsrep_cert_deps_distance
● Max ~4 * #CPUcores
Galera Cluster Benefits
41
www.codership.com
Galera Cluster
➢ Good Performance
➢ Optimistic concurrency control
➢ Virtually synchronous replication
➢ Parallel Replication
➢ Optimized Group Communication
➢ 99.99% transparent
➢ InnoDB look & feel
➢ Automatic node joining
➢ Works in LAN / WAN / Cloud
42
www.codership.com
Galera Cluster
➢ Synchronous multi-master cluster
➢ no data loss
➢ no slave lag
➢ no slave failover
➢ For MySQL/MariaDB InnoDB
➢ 3 or more nodes needed for HA
➢ No single point of failure
52
www.codership.com
Synchronous Replication
That's more like it !!
53
www.codership.com
Synchronous Replication
That's more like it !!
Row based
54
www.codership.com
Synchronous Replication
That's more like it !!
Multi-Master
Row based
55
www.codership.com
Synchronous Replication
That's more like it !!
Multi-Master
All have Oxford master degree
Row based
56
www.codership.com
Synchronous Replication
That's more like it !!
Multi-Master
All have Oxford master degree
Synchronous
Row based
57
www.codership.com
Synchronous Replication
That's more like it !!
Top notch performance
Multi-Master
All have Oxford master degree
Synchronous
Row based
58
www.codership.com
Synchronous Replication
That's more like it !!
Top notch performance
Multi-Master
All have Oxford master degree
Arbitrator
Synchronous
Row based
Automatic Node Joining
60
www.codership.com
MySQL MySQL
Automatic Node Joining
Galera Replication
joiner
Cluster handshake
61
www.codership.com
MySQL Donor
Automatic Node Joining
Galera Replication
joiner
Send state
62
www.codership.com
MySQL MySQL
Automatic Node Joining
Galera Replication
joiner
Catch up
Slave queue
63
www.codership.com
MySQL MySQL
Automatic Node Joining
Galera Replication
MySQL
Migrating to Galera Cluster
65
www.codership.com
Migrating to Galera Clustering
a
MySQL
slave
MySQL
master
MySQL master slave hierarchy
66
www.codership.com
MySQL
slave
MySQL
master
Galera
Node 1
Migrating to Galera Clustering
a
Install first Galera node to
operate as MySQL slave
67
www.codership.com
MySQL
slave
MySQL
master
Galera
Node 1
Migrating to Galera Clustering
a
promote Galera node to
operate as one node cluster
68
www.codership.com
MySQL
slave
MySQL
master
Galera
Node 1
Migrating to Galera Clustering
a
Join more nodes in Galera
slave cluster
Galera
Node 2
Galera
Node 3
69
www.codership.com
MySQL
slave
MySQL
master
Galera
Node 1
Migrating to Galera Clustering
a
Move traffic to Galera cluster
Galera
Node 2
Galera
Node 3
70
www.codership.com
Galera
Node 1
Migrating to Galera Clustering
a
Drop obsolete MySQL servers
Galera
Node 2
Galera
Node 3
Galera Project
72
www.codership.com
Galera Project
● Galera Cluster for MySQL
● 5 years development
● based on MySQL server community edition
● Fully open source
● Active community
● ~3 releases per year
● Latest release 2.3
● Major release 3.0 in the works
● MariaDB Galera Cluster 5.5.29 GA !!
73
Who is using Galera?
74
www.codership.com
Galera Project
MySQL
MariaDB
merge
merge
MySQL Community Edition
MariaDBGalera Cluster for MySQL
MariaDB Features
API
MySQL
Galera Replication plugin
75
www.codership.com
Galera Project
API
Galera Replication plugin
API
MariaDB
MySQL Community Edition
MariaDB Galera Cluster
MySQL
Galera Cluster for MySQL
merge
Galera Replication plugin
MySQL
76
www.codership.com
Galera Support
Codership
Level 3 support, Galera
MontyProgram
Level 3 Support, MariaDB
Galera
Cluster
MariaDB
Galera
Cluster
SkySQL
Support Subscriptions
Questions?
Thank you for listening!
Happy Clustering :-)
High Availability with Galera Cluster - SkySQL Road Show 2013 in Berlin

High Availability with Galera Cluster - SkySQL Road Show 2013 in Berlin