68
G a l e r a C l u s t e r Seppo Jaakola Codership

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

Embed Size (px)

DESCRIPTION

High Availability with Galera Cluster by Seppo Jaakkola, Codership at the SkySQL Road Show 2013 in Berlin 18.6.2013

Citation preview

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

G a l e r a C l u s t e r

Seppo JaakolaCodership

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

2www.codership.com

Agenda

● The Meaning of Galera● Galera Cluster Short Introduction● Migrating to Galera Cluster● Galera Project

● MariaDB Galera Cluster 5.5.29 GA

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

3www.codership.com

What is the Meaning of Galera ?

Turns out it has different semantics in:● Italy● Uruguay● Brazil● Spain, Portugal, Russia...

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

4www.codership.com

Galera in Italy

Che cosa significa la parola galera?

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

5www.codership.com

Galera in Italy

Che cosa significa la parola galera?

Jail / Prison

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

6www.codership.com

Galera in Italy

Che cosa significa la parola galera?

PoliziottoJail / Prison

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

7www.codership.com

Otto Poliziotto ?

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

8www.codership.com

Galera in Uruguay

Que significa galera en Uruguai?

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

9www.codership.com

Galera in Uruguay

Que significaca galera en Uruguai?

Traditional tall hat

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

10www.codership.com

Galera in Brazil

Como sobre em Brazil?

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

11www.codership.com

Galera in Brazil

A Group of Happy People

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

12www.codership.com

Galera in Spain, Portugal, Russia...

Here's the correct meaning for Galera...

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

13www.codership.com

Galera in Spain, Portugal, Russia...

Galley

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

Galera Cluster

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

15www.codership.com

MariaDB

Multi-Master Replication

Galera Replication

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

16www.codership.com

MariaDB MariaDB

Multi-Master Replication

Galera Replication

There can be several nodes

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

17www.codership.com

MariaDB MariaDB MariaDB

Multi-Master Replication

Galera Replication

There can be several nodes

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

18www.codership.com

MariaDB MariaDB MariaDB

Multi-Master Replication

Galera Replication

Client can connect to any node

There can be several nodes

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

19www.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

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

20www.codership.com

MariaDB MariaDB MariaDB

Multi-Master Replication

Galera ReplicationReplication 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

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

21www.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

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

22www.codership.com

MariaDB MariaDB MariaDB

Synchronous Replication

aGalera Replication

Read & write

Transaction is processed locally up to commit time

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

23www.codership.com

MariaDB MariaDB MariaDB

Synchronous Replication

Galera Replication

commit

Transaction's write set is replicated to whole cluster

Slave queueSlave queue

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

24www.codership.com

Galera Replication

MariaDB MariaDB MariaDB

Synchronous Replication

OK

Client gets OK status

Slave queueSlave queue

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

25www.codership.com

Galera Replication

MariaDB MariaDB MariaDB

Synchronous Replication

Transaction is applied in slaves

Slave queueSlave queue

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

26www.codership.com

MariaDB MariaDB MariaDB

How node failures are handled

a

Galera Replication

Load Balancing

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

27www.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

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

Optimistic Concurrency Control

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

29www.codership.com

Galera ReplicationA

Optimistic Concurrency Control

commit

Trx A

B

commit

Trx B

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

30www.codership.com

Galera ReplicationA

Optimistic Concurrency Control

commit

Trx A

B

commit

Trx B

DEADLOCK eror

ROLLBACK

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

31www.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

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

32www.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

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

Parallel Replication

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

34www.codership.com

MariaDB

Parallel Replication

Slave queue

Slave thd Slave thdAny number of slave applier threads can be started

Slave control

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

35www.codership.com

MariaDB

Parallel Replication

Slave queue

Slave thd Slave thdAny number of slave applier threads can be started

Slave control assigns write sets for slave appliers

Slave control

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

36www.codership.com

MariaDB

Parallel Replication

Slave queue

Slave thd Slave thdAny number of slave applier threads can be started

Slave control assigns write sets for slave appliers

Slave control is on ROW levelSlave control

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

38www.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

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

39www.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

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

Galera Cluster Benefits

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

41www.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

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

42www.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

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

52www.codership.com

Synchronous Replication

That's more like it !!

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

53www.codership.com

Synchronous Replication

That's more like it !!

Row based

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

54www.codership.com

Synchronous Replication

That's more like it !!

Multi-Master

Row based

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

55www.codership.com

Synchronous Replication

That's more like it !!

Multi-MasterAll have Oxford master degree

Row based

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

56www.codership.com

Synchronous Replication

That's more like it !!

Multi-MasterAll have Oxford master degree

Synchronous

Row based

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

57www.codership.com

Synchronous Replication

That's more like it !!

Top notch performance

Multi-MasterAll have Oxford master degree

Synchronous

Row based

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

58www.codership.com

Synchronous Replication

That's more like it !!

Top notch performance

Multi-MasterAll have Oxford master degree

Arbitrator

Synchronous

Row based

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

Automatic Node Joining

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

60www.codership.com

MySQL MySQL

Automatic Node Joining

Galera Replication

joiner

Cluster handshake

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

61www.codership.com

MySQL Donor

Automatic Node Joining

Galera Replication

joiner

Send state

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

62www.codership.com

MySQL MySQL

Automatic Node Joining

Galera Replication

joinerCatch up

Slave queue

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

63www.codership.com

MySQL MySQL

Automatic Node Joining

Galera Replication

MySQL

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

Migrating to Galera Cluster

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

65www.codership.com

Migrating to Galera Clustering

a

MySQLslave

MySQLmaster

MySQL master slave hierarchy

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

66www.codership.com

MySQLslave

MySQLmaster

GaleraNode 1

Migrating to Galera Clustering

a

Install first Galera node to operate as MySQL slave

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

67www.codership.com

MySQLslave

MySQLmaster

GaleraNode 1

Migrating to Galera Clustering

a

promote Galera node to operate as one node cluster

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

68www.codership.com

MySQLslave

MySQLmaster

GaleraNode 1

Migrating to Galera Clustering

a

Join more nodes in Galera slave cluster

GaleraNode 2

GaleraNode 3

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

69www.codership.com

MySQLslave

MySQLmaster

GaleraNode 1

Migrating to Galera Clustering

a

Move traffic to Galera cluster

GaleraNode 2

GaleraNode 3

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

70www.codership.com

GaleraNode 1

Migrating to Galera Clustering

a

Drop obsolete MySQL servers

GaleraNode 2

GaleraNode 3

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

Galera Project

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

72www.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 !!

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

73

Who is using Galera?

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

74www.codership.com

Galera Project

MySQL

MariaDBmerge

merge

MySQL Community Edition

MariaDBGalera Cluster for MySQL

MariaDB FeaturesAPI

MySQL

Galera Replication plugin

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

75www.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

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

76www.codership.com

Galera Support

CodershipLevel 3 support, Galera

MontyProgramLevel 3 Support, MariaDB

GaleraCluster

MariaDBGaleraCluster

SkySQLSupport Subscriptions

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

Questions?

Thank you for listening!Happy Clustering :-)

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