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

Preview:

DESCRIPTION

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

Citation preview

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

Seppo JaakolaCodership

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

3www.codership.com

What is the Meaning of Galera ?

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

4www.codership.com

Galera in Italy

Che cosa significa la parola galera?

5www.codership.com

Galera in Italy

Che cosa significa la parola galera?

Jail / Prison

6www.codership.com

Galera in Italy

Che cosa significa la parola galera?

PoliziottoJail / Prison

7www.codership.com

Otto Poliziotto ?

8www.codership.com

Galera in Uruguay

Que significa galera en Uruguai?

9www.codership.com

Galera in Uruguay

Que significaca galera en Uruguai?

Traditional tall hat

10www.codership.com

Galera in Brazil

Como sobre em Brazil?

11www.codership.com

Galera in Brazil

A Group of Happy People

12www.codership.com

Galera in Spain, Portugal, Russia...

Here's the correct meaning for Galera...

13www.codership.com

Galera in Spain, Portugal, Russia...

Galley

Galera Cluster

15www.codership.com

MariaDB

Multi-Master Replication

Galera Replication

16www.codership.com

MariaDB MariaDB

Multi-Master Replication

Galera Replication

There can be several nodes

17www.codership.com

MariaDB MariaDB MariaDB

Multi-Master Replication

Galera Replication

There can be several nodes

18www.codership.com

MariaDB MariaDB MariaDB

Multi-Master Replication

Galera Replication

Client can connect to any node

There can be several nodes

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

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

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

22www.codership.com

MariaDB MariaDB MariaDB

Synchronous Replication

aGalera Replication

Read & write

Transaction is processed locally up to commit time

23www.codership.com

MariaDB MariaDB MariaDB

Synchronous Replication

Galera Replication

commit

Transaction's write set is replicated to whole cluster

Slave queueSlave queue

24www.codership.com

Galera Replication

MariaDB MariaDB MariaDB

Synchronous Replication

OK

Client gets OK status

Slave queueSlave queue

25www.codership.com

Galera Replication

MariaDB MariaDB MariaDB

Synchronous Replication

Transaction is applied in slaves

Slave queueSlave queue

26www.codership.com

MariaDB MariaDB MariaDB

How node failures are handled

a

Galera Replication

Load Balancing

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

Optimistic Concurrency Control

29www.codership.com

Galera ReplicationA

Optimistic Concurrency Control

commit

Trx A

B

commit

Trx B

30www.codership.com

Galera ReplicationA

Optimistic Concurrency Control

commit

Trx A

B

commit

Trx B

DEADLOCK eror

ROLLBACK

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

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

Parallel Replication

34www.codership.com

MariaDB

Parallel Replication

Slave queue

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

Slave control

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

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

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

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

Galera Cluster Benefits

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

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

52www.codership.com

Synchronous Replication

That's more like it !!

53www.codership.com

Synchronous Replication

That's more like it !!

Row based

54www.codership.com

Synchronous Replication

That's more like it !!

Multi-Master

Row based

55www.codership.com

Synchronous Replication

That's more like it !!

Multi-MasterAll have Oxford master degree

Row based

56www.codership.com

Synchronous Replication

That's more like it !!

Multi-MasterAll have Oxford master degree

Synchronous

Row based

57www.codership.com

Synchronous Replication

That's more like it !!

Top notch performance

Multi-MasterAll have Oxford master degree

Synchronous

Row based

58www.codership.com

Synchronous Replication

That's more like it !!

Top notch performance

Multi-MasterAll have Oxford master degree

Arbitrator

Synchronous

Row based

Automatic Node Joining

60www.codership.com

MySQL MySQL

Automatic Node Joining

Galera Replication

joiner

Cluster handshake

61www.codership.com

MySQL Donor

Automatic Node Joining

Galera Replication

joiner

Send state

62www.codership.com

MySQL MySQL

Automatic Node Joining

Galera Replication

joinerCatch up

Slave queue

63www.codership.com

MySQL MySQL

Automatic Node Joining

Galera Replication

MySQL

Migrating to Galera Cluster

65www.codership.com

Migrating to Galera Clustering

a

MySQLslave

MySQLmaster

MySQL master slave hierarchy

66www.codership.com

MySQLslave

MySQLmaster

GaleraNode 1

Migrating to Galera Clustering

a

Install first Galera node to operate as MySQL slave

67www.codership.com

MySQLslave

MySQLmaster

GaleraNode 1

Migrating to Galera Clustering

a

promote Galera node to operate as one node cluster

68www.codership.com

MySQLslave

MySQLmaster

GaleraNode 1

Migrating to Galera Clustering

a

Join more nodes in Galera slave cluster

GaleraNode 2

GaleraNode 3

69www.codership.com

MySQLslave

MySQLmaster

GaleraNode 1

Migrating to Galera Clustering

a

Move traffic to Galera cluster

GaleraNode 2

GaleraNode 3

70www.codership.com

GaleraNode 1

Migrating to Galera Clustering

a

Drop obsolete MySQL servers

GaleraNode 2

GaleraNode 3

Galera Project

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 !!

73

Who is using Galera?

74www.codership.com

Galera Project

MySQL

MariaDBmerge

merge

MySQL Community Edition

MariaDBGalera Cluster for MySQL

MariaDB FeaturesAPI

MySQL

Galera Replication plugin

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

76www.codership.com

Galera Support

CodershipLevel 3 support, Galera

MontyProgramLevel 3 Support, MariaDB

GaleraCluster

MariaDBGaleraCluster

SkySQLSupport Subscriptions

Questions?

Thank you for listening!Happy Clustering :-)

Recommended