MySQL HA Percona cluster @ MySQL Meetup Mumbai

23
1 MySQL HA Solution - Percona Cluster

description

Percona Cluster ( Galera ) is one of the best database solution that provides synchronous replication. The feature like automatic recovery, GTID and multi threaded replication makes it powerful along with ( XtraDB and Xtrabackup ). A good solution for MySQL HA.

Transcript of MySQL HA Percona cluster @ MySQL Meetup Mumbai

Page 1: MySQL HA Percona cluster @ MySQL Meetup Mumbai

1

MySQL HA Solution - Percona Cluster

Page 2: MySQL HA Percona cluster @ MySQL Meetup Mumbai

Agenda

• Need for HA• Principle of Distributed computing.• MySQL HA Solutions Available. • Introduction to Galera.• Percona Cluster.• Node Recovery.• Things to be considered.

2

Page 3: MySQL HA Percona cluster @ MySQL Meetup Mumbai

3

• Senior MySQL DBA Yahoo!

• Focus MySQL HA and Sharding• MySQL Experience 4 Years• Student MS ( FOSS ) MIT • Blogger remotemysqldba.blogspot.in

About Myself : P.R.KarthiK

Page 4: MySQL HA Percona cluster @ MySQL Meetup Mumbai

Need For HA

• Site Reliability • Failover • Disaster Recovery• Scheduled / Unscheduled downtime.• Avoid Single Point Failure

4

Page 5: MySQL HA Percona cluster @ MySQL Meetup Mumbai

Principle of Distributed Computing

CAP Theorem

5

Page 6: MySQL HA Percona cluster @ MySQL Meetup Mumbai

Principle of Distributed Computing

CAP Theorem

•Only Two out of three

AP – MySQL Replication

CA – Galera Cluster

6

Page 7: MySQL HA Percona cluster @ MySQL Meetup Mumbai

MySQL HA Solutions Available

• Master – Slave• Master – Master• Single Writer• NDB Cluster ( MySQL )• Galera Cluster• Tungsten Replicator• Storage Level Replication ( DRDB)

7

Page 8: MySQL HA Percona cluster @ MySQL Meetup Mumbai

Introduction To Galera

• Founded By Codership• Synchronous Replication• Parallel Replication• Multi-Threaded• Automated node recovery• Zero slave lag• Read/ Write Scalable• WAN Based Optimization.• A True Open Source.

8

Page 9: MySQL HA Percona cluster @ MySQL Meetup Mumbai

Introduction To Galera

What is Galera ?

Galera is a replication plugin for the synchronous and multi-master replication to achieve HA.

“Wsrep_provider_options” controls library.

Percona ClusterMariaDB Cluster Used over MySQL

9

Page 10: MySQL HA Percona cluster @ MySQL Meetup Mumbai

Introduction To Galera

• Shared nothing Architecture.• Network is the heart.

What is wsrep ? (Write Set REPlication )

It is an API to connect the Galera library and control characteristics. It helps to implement synchronous replication and certification based multi-master-replication.

10

Page 11: MySQL HA Percona cluster @ MySQL Meetup Mumbai

Introduction To Galera

Simple Architecture

11

Page 12: MySQL HA Percona cluster @ MySQL Meetup Mumbai

Percona Cluster

• Use Galera Library • XtraDB • Xtrabackup

+ +

12

Page 13: MySQL HA Percona cluster @ MySQL Meetup Mumbai

Percona Cluster

Why Percona Server ?

•Enhanced InnoDB (XtraDB )•Performance Improvement•Xtrabackup ( Makes SST better )•A better MySQL

13

Page 14: MySQL HA Percona cluster @ MySQL Meetup Mumbai

Transaction in Galera.

• Transaction is handled by Galera Plugin.• Uses traditional dual phase commit.• It also handles locking.• Uses the optimistic locking method.• The commits are based on certifications (keys).• Smaller transaction are always better. • Increase in network latency increases query time.

14

Page 15: MySQL HA Percona cluster @ MySQL Meetup Mumbai

Transaction in Galera.

15

Page 16: MySQL HA Percona cluster @ MySQL Meetup Mumbai

Transaction in Galera.

• Synchronous ( Virtual ) Replication.• Wsrep_causal_reads=ON ( true synchronous)• Auto_increment is handled by cluster.• Uses GTID for Transaction.

16

Page 17: MySQL HA Percona cluster @ MySQL Meetup Mumbai

Node Recovery

17

• Node recovery is automated.• Validates the gcache for state files.• Chooses the State Transfer method

1) IST (Incremental State Transfer)

2)SST (State Snapshot Transfer )

Page 18: MySQL HA Percona cluster @ MySQL Meetup Mumbai

Node Recovery

18

IST :•Recover from write sets in gcache.•Faster recovery method.•Have good gcache size.

Page 19: MySQL HA Percona cluster @ MySQL Meetup Mumbai

Node Recovery

19

SST :

State Snapshot Transfer the complete transfer ( Cloning ) of data to recreate a node.

*when not in Gcache

*Adding a new node

Different Methods of SST

Xtrabackup (best ) , rsync , mysqldump .

Page 20: MySQL HA Percona cluster @ MySQL Meetup Mumbai

Node Recovery

20

Validate Node after recovery

Wsrep_local_state_Comment

1)Joining

2)Donor/desynced

3)Joined

4)Synced

Page 21: MySQL HA Percona cluster @ MySQL Meetup Mumbai

Things should be considered.

21

• Support only Transactional engines.• Row Based replication.• Read commited Isolation.• Innodb_autoinc_lock_mode=2.• Avoid huge transactions.• Wsrep_max_ws_rows (128K)• Wsrep_max_ws_size. (1G)• Network is the heart.• Keep the DB design simple

Page 22: MySQL HA Percona cluster @ MySQL Meetup Mumbai

IMAGE Courtesy

•Galera and Percona cluster documentation•http://opentodo.net/2012/12/mysql-multi-master-replication-with-galera/

22

Page 23: MySQL HA Percona cluster @ MySQL Meetup Mumbai

Queries ?

remotemysqldba.blogspot.in

23