60
©Continuent 2012. State of the Art in MySQL HA and Replication Robert Hodges, CEO Giuseppe Maxia, Director of QA 1 Tuesday, November 13, 12

State of the art of MySQL replication and clustering

Embed Size (px)

DESCRIPTION

State of the art of MySQL replication and clustering

Citation preview

Page 1: State of the art of MySQL replication and clustering

©Continuent 2012.

State of the Art in MySQL HA and Replication

Robert Hodges, CEOGiuseppe Maxia, Director of QA

1Tuesday, November 13, 12

Page 2: State of the art of MySQL replication and clustering

©Continuent 2012

Introducing Continuent

2

• The leading provider of clustering and replication for open source DBMS

• Our Product: Continuent Tungsten

• Clustering - Commercial-grade HA, performance scaling and data management for MySQL

• Replication - Flexible, high-performance data movement

2Tuesday, November 13, 12

Page 3: State of the art of MySQL replication and clustering

©Continuent 2012

Quick Continuent Facts

• Largest Tungsten clustering installation processes about 500M transactions each day

• Tungsten Replicator was application of the year at the 2011 MySQL User Conference

• Continuent is well known in the MySQL community for its clustering and replication

• Over 90 customers currently deployed

3

3Tuesday, November 13, 12

Page 4: State of the art of MySQL replication and clustering

©Continuent 2012

A Few Continuent Customers

4

4Tuesday, November 13, 12

Page 5: State of the art of MySQL replication and clustering

©Continuent 2012 5

Future-Proof HA and Replication for MySQL

5Tuesday, November 13, 12

Page 6: State of the art of MySQL replication and clustering

©Continuent 2012

What is Future-Proo!ng?

• Future-proo!ng = creating systems that last while parts change and improve

• MySQL is not losing out to other solutions for data management

• The real problem is using MySQL as a building block with other technologies that are changing rapidly

6

6Tuesday, November 13, 12

Page 7: State of the art of MySQL replication and clustering

©Continuent 2012

But Wait... Isn’t MySQL Dead??

7

MySQL“You were so open”

BornMay 25, 1995

Died2008, 2009, 2010,

2011, 2012, ...

7Tuesday, November 13, 12

Page 8: State of the art of MySQL replication and clustering

©Continuent 2012

Oracle/MySQL 5.6 Replication (On the Way)

• Global transaction IDs

• Parallel slave threads

• Crash safe slaves

• Optimized row updates

• Time delay replication

• Informational log events

8

8Tuesday, November 13, 12

Page 9: State of the art of MySQL replication and clustering

©Continuent 2012

Galera Synchronous Clusters (New Arrival in 2012)

• Multi-master for InnoDB

• Synchronous replication avoids data loss

• Automatic cluster membership management

• Simple node provisioning model

• Based on innovative state-machine work from Fernando Pedone

9

9Tuesday, November 13, 12

Page 10: State of the art of MySQL replication and clustering

©Continuent 2012

Tungsten Async Replication (2011 Belle of the Ball)

• All 5.6 features including parallel replication for MySQL 5.0 onwards

• Optimized support for failover

• Programmable transaction !ltering

• Backup/restore integration

• Multi-master, fan-in, and star replication

• Replication to/from Oracle and batch loading of data warehouses

• Replication to MongoDB

10

10Tuesday, November 13, 12

Page 11: State of the art of MySQL replication and clustering

©Continuent 2012

Not Bad for a Dying Market

11

MySQL,'88%'

NoSQL,'5%'

NewSQL,'2%'

My/NewSQL,'5%'

0"100"200"300"400"500"600"700"800"900"1000"

2011" 2012" 2013" 2014" 2015"

THE$TOTAL$MARKET$FOR$MYSQL,$NOSQL$$AND$NEWSQL$$

Text

(451Group)

11Tuesday, November 13, 12

Page 12: State of the art of MySQL replication and clustering

©Continuent 2012

• Cloud and Big Data investment dwarf the MySQL marketplace

MySQL Is Part of Bigger Trends

12

12Tuesday, November 13, 12

Page 13: State of the art of MySQL replication and clustering

©Continuent 2012

21st Century CRM/Call Center

13

CRM WebApplication

Telephony Data Streams

CRM WebApplication

Telephony Data Streams

Legacy Oracle

Fat ClientAccounting

Call Session Data

Hadoop Analytics

Online TransactionProcessing

Amazon Web ServicesOn-Premise

13Tuesday, November 13, 12

Page 14: State of the art of MySQL replication and clustering

©Continuent 2012

Revolutionary Challenges for MySQL

• Failures in unstable cloud environments

• Zero-downtime maintenance

• Rapidly growing data volumes, esp. in cloud

• Distributing data to geographical regions

• Integration between MySQL, NoSQL, commercial RDBMS

• Supplying real-time analytics

• Technology upgrade/replacement

14

14Tuesday, November 13, 12

Page 15: State of the art of MySQL replication and clustering

©Continuent 2012

Future-Proofed HA and Replication

15

Encapsulated, fault-tolerant, horizontally scalable, globally

accessible, integrated data

Data Fabric

15Tuesday, November 13, 12

Page 16: State of the art of MySQL replication and clustering

©Continuent 2012

Data Fabric Design Patterns

• Fabric Connector

• Fault-Tolerant Data Service

• Sharded Data Service

• Multi-Site Data Service

• Real-Time Data Bridge

16

16Tuesday, November 13, 12

Page 17: State of the art of MySQL replication and clustering

©Continuent 2012

• Single point of entry for applications

• Service catalog locates data within fabric

• Transparent connectivity, multiple protocols

• Security, auditing, performance management

1. Fabric Connector

17

FabricConnector

FabricConnector

ApplicationStack

ApplicationStack

17Tuesday, November 13, 12

Page 18: State of the art of MySQL replication and clustering

©Continuent 2012

2. Fault-Tolerant Data Service

• Encapsulate redundant database copies

• Sync and async clustering models

• Protect against local DBMS failure

• Rolling maintenance of replicas

18

Master/Slave

Multi-Master

18Tuesday, November 13, 12

Page 19: State of the art of MySQL replication and clustering

©Continuent 2012

3. Sharded Data Service

• Partition datasets based on RAM / storage speed / resident set size

• Multiple buckets per server

• Look-up methods for locating data in buckets

• Re-sharding / migration for high growth

19

19Tuesday, November 13, 12

Page 20: State of the art of MySQL replication and clustering

©Continuent 2012

4. Multi-Site Data Service

• Robust protection against region/site failures

• Geographic distribution of data

• Primary/DR vs. multi-master

• Eventually consistent replication for SQL

20

Amazon East

Rackspace DFWAPAC TokyoUS East

EU West

20Tuesday, November 13, 12

Page 21: State of the art of MySQL replication and clustering

©Continuent 2012

5. Real-Time Data Bridge

• Replicate from logs in real-time

• Enable apps to get data from one data source

• Heterogeneous transfer and transformation

• High performance, low application impact

21

Bridge

Bridge

Bridge

21Tuesday, November 13, 12

Page 22: State of the art of MySQL replication and clustering

©Continuent 2012

Future-Proofed CRM/Call Center Data

22

CRM WebApplication

CRM WebApplication

Legacy Oracle

Fat ClientAccounting

Bridge

Bridge

FabricConnector

FabricConnector

OLTP Primary

Data Marts

Bridge

Bridge HadoopAnalytics

Telephony Data Streams

Telephony Data Streams

FabricConnector

FabricConnector

FabricConnector

OLTP DR

Bridge

Call Session Data

22Tuesday, November 13, 12

Page 23: State of the art of MySQL replication and clustering

©Continuent 2012

Future-Proofed CRM/Call Center Data

23

CRM WebApplication

CRM WebApplication

Legacy Oracle

Fat ClientAccounting

Bridge

Bridge

FabricConnector

FabricConnector

OLTP Primary

Data Marts

Bridge

Bridge HadoopAnalytics

Telephony Data Streams

Telephony Data Streams

FabricConnector

FabricConnector

OLTP DR

Bridge

Call Session Data

FabricConnector

23Tuesday, November 13, 12

Page 24: State of the art of MySQL replication and clustering

©Continuent 2012 24

Enabling Data Fabric With Tungsten

24Tuesday, November 13, 12

Page 25: State of the art of MySQL replication and clustering

©Continuent 2012

Tungsten Fault Tolerant Data Service

25

Tungsten clusters combine o"-the-shelf open source DBMS servers into data services with:

• 24x7 data access • Scaling of load on replicas• Simple management commands

...without app changes or data migration

AmazonUS West

apache/php

GonzoPortal.com

Connector Connector

25Tuesday, November 13, 12

Page 26: State of the art of MySQL replication and clustering

©Continuent 2012

Doesn’t Replication Do This Already?

26

Application

Libmysqlclient.a

Application

Libmysqlclient.a

Replicator

Db2

Replicator

Db3Db1

Replicator

Slave SlaveMaster

26Tuesday, November 13, 12

Page 27: State of the art of MySQL replication and clustering

©Continuent 2012

Replication Limitations

Replication alone cannot enable constant access to data...

• What happens if the master fails?

• What happens if a slave is lagging too far behind to be usable?

• How do I maintain the DBMS without stopping apps?

27

27Tuesday, November 13, 12

Page 28: State of the art of MySQL replication and clustering

©Continuent 2012

From Replicating to a Data Service

28

Application

Tungsten Connector

Application

Tungsten Connector

Replicator

Db2

Replicator

Db3Db1

Replicator

Slave SlaveMaster

Manager Manager Manager

Monitoring and Control

Monitoring and Control

Data Service: sjc

28Tuesday, November 13, 12

Page 29: State of the art of MySQL replication and clustering

©Continuent 2012

Basic Operations

29

• Switch -- Promote a slave node to master

• Shun -- Kick node out of cluster

• Welcome -- Return node to cluster

• Backup -- Run a backup

• Restore -- [Re-]provision a node

• Recover -- Return a broken node to slave

• Heartbeat -- Check cluster liveness

29Tuesday, November 13, 12

Page 30: State of the art of MySQL replication and clustering

©Continuent 2012

Automatic Failover

30

Application

Tungsten Connector

30Tuesday, November 13, 12

Page 31: State of the art of MySQL replication and clustering

©Continuent 2012

Automatic Failover

31

Application

Tungsten Connector

1. Detect non-responsivemaster

2. Halt master connections

31Tuesday, November 13, 12

Page 32: State of the art of MySQL replication and clustering

©Continuent 2012

Automatic Failover

32

Application

Tungsten Connector

3. Select most advanced slave and wait for pending transactions to apply

32Tuesday, November 13, 12

Page 33: State of the art of MySQL replication and clustering

©Continuent 2012

Automatic Failover

33

Application

Tungsten Connector

4. Promote to master, reconfigure slave(s), and re-enable connections

33Tuesday, November 13, 12

Page 34: State of the art of MySQL replication and clustering

©Continuent 2012

Automatic Failover

34

Application

Tungsten Connector

5. Recover failed master

34Tuesday, November 13, 12

Page 35: State of the art of MySQL replication and clustering

©Continuent 2012

Rolling SQL Schema Upgrade

35

Final UpgradeSwitchSlave Upgrade Slave Upgrade

• Shun slave 1, run upgrade, and return to cluster. Discard and recover on failure

• Upgrade old master. Cluster schema is now fully upgraded

• Repeat for additional slave(s)

• Switch master to promote an upgraded slave

35Tuesday, November 13, 12

Page 36: State of the art of MySQL replication and clustering

©Continuent 2012

Backup, Recovery, and Restore

36

• Backups

/cluster > datasource DB1 backup

• Recover

/cluster > datasource DB2 recover

• Restore

/cluster > datasource DB2 restore

• Out-of-box support for mysqldump/XtraBackup; simple integration for others

36Tuesday, November 13, 12

Page 37: State of the art of MySQL replication and clustering

©Continuent 2012 37

Data Fabric Connectivity

37Tuesday, November 13, 12

Page 38: State of the art of MySQL replication and clustering

©Continuent 2012

Tungsten Connector Basics

• Any MySQL/PostgreSQL client can connect

• Initiates connections using JDBC

38

App NativeprotocolCOM_QUERY

COM_INIT_DBCOM_DROP_DB

Connector

38Tuesday, November 13, 12

Page 39: State of the art of MySQL replication and clustering

©Continuent 2012

Tungsten Connector Basics

• Pass-through operation after connection

• Full transparency & low overhead for clients

39

App

Protocol packetCOM_QUERY

select * from t

ConnectorProtocol packet

OKResultSet Rows:1

39Tuesday, November 13, 12

Page 40: State of the art of MySQL replication and clustering

©Continuent 2012

Simple Read/Write Splitting

• Very fast, easy-to-understand scaling model

• Transactions go to master

• Auto-commit SELECTs go to slaves, if available, but...

• Reads potentially outdated data

• Ephemeral SQL objects won’t be available

• May miss: select update_function()

40

40Tuesday, November 13, 12

Page 41: State of the art of MySQL replication and clustering

©Continuent 2012

SmartScale Session Load Balancing

41

App

Connect/Write

Connector

TransactionHistory Log

Slavereplay

position

Session xSession y

Slave DBMS

MasterDBMS

Slave DBMS

41Tuesday, November 13, 12

Page 42: State of the art of MySQL replication and clustering

©Continuent 2012

SmartScale Session Load Balancing

42

AppRead

Connector

TransactionHistory Log

Slavereplay

position

Session xSession y

Slave DBMS

MasterDBMS

Slave DBMS

42Tuesday, November 13, 12

Page 43: State of the art of MySQL replication and clustering

©Continuent 2012

SmartScale Session Load Balancing

43

AppRead

Connector

TransactionHistory Log

Slavereplay

position

Session x

Slave DBMS

MasterDBMS

Slave DBMS

43Tuesday, November 13, 12

Page 44: State of the art of MySQL replication and clustering

©Continuent 2012 44

Multi-Site Data Service

44Tuesday, November 13, 12

Page 45: State of the art of MySQL replication and clustering

©Continuent 2012

Multi-Master Pattern

45

• Updates on 2+ sites (active-active mode)

• Enables geographic distribution of data

• No failover necessary if network fails or site becomes unavailable

• Not all applications can handle multi-master

• Applications must avoid con!icts

• Careful testing required

• Restoration of broken systems may not be easy

45Tuesday, November 13, 12

Page 46: State of the art of MySQL replication and clustering

©Continuent 2012

Simple Multi-Master Con!guration

46

NYC FrankfurtReplicator

fra (master)

nyc (slave)

Replicator

fra (slave)

nyc (master)

Database-to-Database

46Tuesday, November 13, 12

Page 47: State of the art of MySQL replication and clustering

©Continuent 2012

Clustered Multi-Master Con!guration

47

NYC Frankfurt

master

slave fra

fra

nyc

nyc

master

slave

47Tuesday, November 13, 12

Page 48: State of the art of MySQL replication and clustering

©Continuent 2012

Clustered Multi-Master Con!guration

48

NYC Frankfurt

slave

master fra

fra

nyc

nyc

master

slave

NYC Master Offline

48Tuesday, November 13, 12

Page 49: State of the art of MySQL replication and clustering

©Continuent 2012

Clustered Multi-Master Con!guration

49

NYC Frankfurt

master

slave fra

fra

nyc

nyc

master

slave

NYC Replicator Offline

49Tuesday, November 13, 12

Page 50: State of the art of MySQL replication and clustering

©Continuent 2012

Complex Multi-Master Topologies

50

StarReplication

AllMasters

50Tuesday, November 13, 12

Page 51: State of the art of MySQL replication and clustering

©Continuent 2012

Primary/DR Pattern

51

• Updates go to primary site master

• DR site receives updates in real time

• Simple command promotion

• Tungsten connectors can route to primary and DR sites

• No application changes required

• Simplest way to protect against region/site failures

51Tuesday, November 13, 12

Page 52: State of the art of MySQL replication and clustering

©Continuent 2012

Tungsten Composite Data Services

52

App Server+ Connector

App Server+ Connector

Master Slave

San Jose New York

sj_nyc

52Tuesday, November 13, 12

Page 53: State of the art of MySQL replication and clustering

©Continuent 2012 53

Real-Time Data Bridge

53Tuesday, November 13, 12

Page 54: State of the art of MySQL replication and clustering

©Continuent 2012

Problem: Real-Time Order Ful!llment

54

Real-Time Replication

MySQL

Web-Facing Sales Purchase Ordering

Oracle

PHP/Perl

Java/JBoss

3M Order Items

1-2M transactions daily

54Tuesday, November 13, 12

Page 55: State of the art of MySQL replication and clustering

©Continuent 2012

How Does Tungsten Do That?

55

MySQL Tungsten Master Replicator

Oracle

Service oracle

MySQLExtractorSpecial Filters* Transform enum to string

binlog_format=row

Tungsten Slave Replicator

Service oracle

Special Filters* Ignore extra tables* Map names to upper case* Optimize updates to remove unchanged columnsMySQL

Binlog

55Tuesday, November 13, 12

Page 56: State of the art of MySQL replication and clustering

©Continuent 2012

Batch Loading to Data Warehouses

56

CsvFile

CsvFile

CsvFile. . .

London

Replicator

Service batch

VerticaData

Warehouse

TransactionHistory Log

MySQLMaster

THL

56Tuesday, November 13, 12

Page 57: State of the art of MySQL replication and clustering

©Continuent 2012

Possibilities for Analytics...

57

OLTP Data

MySQL MasterComplex, near real-time reporting

Light-weight, real-time operational status

Web-facing mini-data marts for SaaS users

57Tuesday, November 13, 12

Page 58: State of the art of MySQL replication and clustering

©Continuent 2012

Getting Started

58

58Tuesday, November 13, 12

Page 59: State of the art of MySQL replication and clustering

©Continuent 2012

How Do I Obtain Tungsten?

59

• Register at Continuent to get downloads for Oracle replication: http://www.continuent.com/downloads/software

• Documentation is available on Continuent website

• MySQL replication is available from Tungsten Replicator project on code.google.comhttp://code.google.com/p/tungsten-replicator/

59Tuesday, November 13, 12

Page 60: State of the art of MySQL replication and clustering

©Continuent 2012.

Continuent Web Page:http://www.continuent.com

Tungsten Replicator 2.0:http://code.google.com/p/tungsten-replicator

Our Blogs:http://scale-out-blog.blogspot.comhttp://datacharmer.org/bloghttp://www.continuent.com/news/blogs

560 S. Winchester Blvd., Suite 500 San Jose, CA 95128 Tel +1 (866) 998-3642 Fax +1 (408) 668-1009e-mail: [email protected]

60Tuesday, November 13, 12