mysql clusters

42
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | MySQL High Availability InnoDB Cluster and NDB Cluster Mark Swarbrick Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

Upload: mark-swarbrick

Post on 13-Apr-2017

159 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

MySQLHighAvailabilityInnoDBClusterandNDBCluster

MarkSwarbrick

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.

Page 2: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

SafeHarborStatementThefollowingisintendedtooutlineourgeneralproductdirecOon.ItisintendedforinformaOonpurposesonly,andmaynotbeincorporatedintoanycontract.Itisnotacommitmenttodeliveranymaterial,code,orfuncOonality,andshouldnotberelieduponinmakingpurchasingdecisions.Thedevelopment,release,andOmingofanyfeaturesorfuncOonalitydescribedforOracle’sproductsremainsatthesolediscreOonofOracle.

2

Page 3: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

AlmostallorganizaOonsrequiretheirmostcriOcalsystemstobehighlyavailable

3

100%

Page 4: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

InnoDBCluster

4

or

NDBCluster

Page 5: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

• MySQLInnoDBCluster– EasyHAbuiltintoMySQL5.7+– Writeconsistency– ReadScalability– AppfailoverusingMySQLRouter– Managementviamysqlsh– InnoDBstorageengine

• MySQLNDBCluster– Inmemorydatabase– AutomaOcsharding– NaOveaccessviaseveralAPI– Read/writeconsistency– Read/writescalability– NDBstorageengine

HowDoTheTwoCompareI

Page 6: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

HowDoTheTwoCompareII

MySQLInnoDBCluster MySQLNDBCluster

StorageEngine InnoDB NDBCLUSTER

DistributedArchitecture Sharednothing Sharednothing

ConsistencyModel WeakConsistency StrongConsistency

Sharding No Yes

ArbitraOon No Yes

LoadBalancing No Yes

NoSQLAPIs MySQLDocumentStore NaOveNDBAPI

OperaOonalComplexity Medium High

AdministraOon Standard(MySQL) Custom(MySQL+NDB)

Page 7: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

InnoDBCluster

7

Page 8: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

InnoDBCluster

8

AppServerswithMySQLRouter

MySQLGroupReplicaOon

MySQLShellSetup,Manage,Orchestrate

“HighAvailabilitybecomesacorefirstclassfeatureofMySQL!”

Page 9: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.| 9

MySQLInnoDBCluster:Vision

“Asingleproduct—MySQL—withhighavailabilityandscalingfeaturesbakedin;providinganintegratedend-to-endsoluEonthatiseasytouse.”

Page 10: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

• OneProduct:MySQL– Allcomponentscreatedtogether– Testedtogether– Packagedtogether

•  EasytoUse– Oneclient:MySQLShell– Easypackaging– IntegratedorchestraOon– Homogenousservers

•  FlexibleandModern– SQLandNoSQLtogether– ProtocolBuffers– Developerfriendly

•  SupportRead/WriteScaleOut– Shardedclusters– FederatedsystemofNreplicasets– Eachreplicasetmanagesashard

10

MySQLInnoDBCluster:Goals

Page 11: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

MySQLConnectorApplicaOon

MySQLRouter

MySQLConnectorApplicaOon

MySQLRouter

MySQLShell

MySQLConnectorApplicaOon

MySQLRouter

MySQLConnectorApplicaOon

MySQLRouter

MySQLInnoDBCluster:HighLevelArchitecture

MySQLInnoDBcluster

MySQLEnterpriseMonitor

Page 12: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

MySQLGroupReplicaOonNa7velydistributedandhighlyavailablereplicasets

Page 13: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

MySQLGroupReplicaOon:WhatIsIt?• GroupReplicaOonlibrary

– ImplementaOonofReplicatedDatabaseStateMachinetheory• MySQLGCSisbasedonPaxos(variantofMencius)

– ProvidesvirtuallysynchronousreplicaOonforMySQL5.7+– SupportedonallMySQLplaGorms

•  Linux,Windows,Solaris,OSX,FreeBSD“MulE-masterupdateanywherereplicaEonpluginforMySQLwithbuilt-inconflictdetec1onandresolu1on,automa1cdistributedrecovery,andgroupmembership.”

13

AppServerswithMySQLRouter

MySQLGroupReplicaOon

MySQLShellSetup,Manage,Orchestrate

Page 14: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

MySQLGroupReplicaOon:WhatDoesItProvide?

• AhighlyavailabledistributedMySQLdatabaseservice– Removestheneedformanuallyhandlingserverfail-over– Providesdistributedfaulttolerance– EnablesAcOve/AcOveupdateanywheresetups– AutomatesreconfiguraOon(adding/removingnodes,crashes,failures)– AutomaOcallydetectsandhandlesconflicts

14

Page 15: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

MySQLGroupReplicaOon:Architecture

NodeTypesR:Trafficrouters/proxies:mysqlrouter,haproxy,sqlproxy,...M:mysqldnodesparOcipaOnginGroupReplicaOon

15

Page 16: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.| 16

MySQLServer:FullStack

Page 17: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

MySQLRouterTransparentapplica7onconnec7onrou7ng

Page 18: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

MySQLRouter:2.1• NaOvesupportforInnoDBclusters

– UnderstandsGroupReplicaOontopology– UOlizesmetadataschemastoredoneachmember

•  BootstrapsitselfandsetsupclientrouOngfortheInnoDBcluster•  AllowsforintelligentclientrouOngintotheInnoDBcluster•  SupportsmulO-masterandsingleprimarymodes

• Coreimprovements– Logging– Monitoring– Performance– Security

18

AppServerswithMySQLRouter

MySQLGroupReplicaOon

MySQLShellSetup,Manage,Orchestrate

labs.mysql.com

Page 19: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

MySQLShellSingletoolfordevelopment,setup,management,orchestra7on,andmonitoring

Page 20: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

MySQLShell

20

Asingleunifiedclientforalladministra7veandopera7onstasks

AppServerswithMySQLRouter

MySQLGroupReplicaOon

MySQLShellSetup,Manage,Orchestrate

• MulO-Language:JavaScript,Python,andSQL– Naturallyscriptable

•  SupportsbothDocumentandRelaOonalmodels•  ExposesfullDevelopmentandAdminAPI”MySQLShellprovidesthedeveloperandDBAwithasingleintuiEve,flexible,andpowerfullinterfaceforallMySQLrelatedtasks!”

Page 21: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

MySQLShell:AdminAPI

• mysql-js>dba.help()•  Theglobalvariable'dba'isusedtoaccesstheMySQLAdminAPI

• PerformDBAoperaOons– ManageMySQLInnoDBclusters

•  Createclusters•  DeployMySQLinstances•  Getclusterinfo•  Start/StopMySQLInstances•  ValidateMySQLinstances…

DatabaseAdministra7onInterface

labs.mysql.com

AppServerswithMySQLRouter

MySQLGroupReplicaOon

MySQLShellSetup,Manage,Orchestrate

Page 22: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

MySQLShell–DeployMySQLInstancesshell>mysqlsh

mysql-js>dba.deployLocalInstance(3306)

mysql-js>dba.deployInstance(‘hanode2:3306’)

mysql-js>dba.deployInstance(‘hanode3:3306’)

22

Page 23: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

MySQLShell–CreateanInnoDBClustermysql-js>\connectroot@hanode1:3306

mysql-js>cluster=dba.createCluster(‘NewAppCluster')

mysql-js>cluster.addInstance('root@hanode2:3306')

mysql-js>cluster.addInstance('root@hanode3:3306')

23

Page 24: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

MySQLShell–AddaMySQLRoutershell>mysqlrouter--bootstraphanode1:3306

shell>mysqlrouter&

shell>mysqlsh--uriroot@localhost:6446

24

Page 25: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

MySQLEnterpriseMonitor• NaOveholisOcsupportforInnoDBclusters

– Topologyviews– Detailedmetricsandgraphs– BestPracOceadvice

• MonitoringofMySQLRouters• MonitoringofGroupReplicaOon

25

Page 26: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

NDBCluster

26

Page 27: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

DrivingDatabaseRequirements

9thApril2015 Copyright2015,oracleand/oritsaffiliates.Allrightsreserved 27

RockSolidAvailability

In-MemoryReal-Time

Performance

ExtremeRead&WriteScalability

ElasOcity

Page 28: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

HLR/HSS

Billing,AuC,VLR

AuC,CallRouOng,Billing

LocaOonUpdates

Pre&PostPaid

• Massivevolumesofwritetraffic• <3msdatabaseresponse• DownOme&losttransacOons=lost$• ExtremlycostsensiOvemarket

MySQL Cluster in Action: http://bit.ly/oRI5tF

NoTrade-Offs:CellularNetwork

Page 29: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

MySQLClusterOverview• MemoryopOmizedtableswithdurability• PredictableLow-Latency,BoundedAccessTimeREAL-TIME

• Auto-Sharding,AcOve-AcOve• ACIDCompliant,OLTP+Real-TimeAnalyOcsHIGHSCALE,READS+WRITES

FULLYELASTIC

•  AcOve-AcOve,Sharednothing,noSinglePointofFailure•  SelfHealing+On-LineOperaOons99.999%AVAILABILITY

•  Key/Value+Complex,RelaOonalQueries•  SQL+Memcached+JavaScript+Java+HTTP/REST&C++SQL+NoSQL

•  OpenSource+CommercialEdiOons,Easytouseanddeploy•  Commodityhardware+Management,MonitoringToolsLOWTCO

9thApril2015 Copyright2015,oracleand/oritsaffiliates.Allrightsreserved 29

•  Addandremovestorageandperformancecapacityinseconds•  Fullycloudenabled

Page 30: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

UserSession

Sessionmanagement

Sessionmanagement

LocaOonUpdates,Charactermovements,...

• Massivevolumesofwritetraffic• <3msdatabaseresponse• DownOme&losttransacOons=lost$• ExtremlysensiOvecrowd

NoTrade-Offs:MassiveParallelOnlineGames

Page 31: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

MySQLClusterArchitecture

MySQLClusterDataNodes

Clients

ApplicaOonLayer

DataLayer

9thApril2015 Copyright2015,oracleand/oritsaffiliates.Allrightsreserved 31

Page 32: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

DataParOOoning/Auto-sharding

17/01/17 Copyright2015,oracleand/oritsaffiliates.Allrightsreserved 32

User-id(PK) Service(PK) Data

1773467253 chat xxx

6257346892 chat xxx

1773467253 photos xxx

7234782739 photos xxx

8235602099 reminders xxx

8437829249 loca7on xxx

MySQLClusterDataNodes

Page 33: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

DataParOOoning/Auto-sharding

17/01/17 Copyright2015,oracleand/oritsaffiliates.Allrightsreserved 33

User-id(PK) Service(PK) Data

1773467253 chat xxx

6257346892 chat xxx

1773467253 photos xxx

7234782739 photos xxx

8235602099 reminders xxx

8437829249 loca7on xxx

MySQLClusterDataNodes

ShardKey

Page 34: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

DataParOOoning/Auto-sharding

17/01/17 Copyright2015,oracleand/oritsaffiliates.Allrightsreserved 34

User-id(PK) Service(PK) Data

1773467253 chat xxx

6257346892 chat xxx

1773467253 photos xxx

7234782739 photos xxx

8235602099 reminders xxx

8437829249 loca7on xxx

MySQLClusterDataNodes

ShardKey

Page 35: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

NodeGroup

DataNode1

• DatatransparentlyshardedbetweenNodeGroups•  EachfragmentacOveinoneDataNodewithsynchronousreplicaOonto2ndDataNodeinsameNodeGroup

17/01/17 Copyright2015,oracleand/oritsaffiliates.Allrightsreserved 35

DataNode2

NodeGroup

DataNode3 DataNode4

DataParOOoning/Auto-sharding

Page 36: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

DataParOOoning/Auto-sharding

• DBAchooseswhichpartofPrimaryKeytouseasshardkey

•  Fragmentforeachrowdecidedbyhashingtheshardingkey

17/01/17 Copyright2015,oracleand/oritsaffiliates.Allrightsreserved 36

User-id(PK) Service(PK) Data

1773467253 chat xxx

6257346892 chat xxx

1773467253 photos xxx

7234782739 photos xxx

8235602099 reminders xxx

8437829249 loca7on xxx

ShardKey

NodeGroup

DataNode1 DataNode2

NodeGroup

DataNode3 DataNode4

Page 37: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

• DataautomaOcallyrearrangedtousenewcapacity• DesignedtobeaslowbackgroundprocessnotimpacOngreal-Omeperformance.

17/01/17 Copyright2015,oracleand/oritsaffiliates.Allrightsreserved 37

NodeGroup

DataNode1 DataNode2

NodeGroup

DataNode3 DataNode4

NodeGroup

DataNode5 DataNode6

On-lineScalingandElasOcityRe-parOoning

Page 38: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

MySQLCluster7.2:1.2BillionUPDATEsperMinute

• NoSQLC++API,flexaSynchbenchmark

•  30xIntelE5-2600IntelServers,2socket,64GB

• ACIDTransacOons,withSynchronousReplicaOon

hxp://www.mysql.com/why-mysql/white-papers/mysql-cluster-benchmarks-1-billion-writes-per-minute/0

5

10

15

20

25

2 4 6 8 10 12 14 16 18 20 22 24 26 28 30

Mill

ions

of U

PDAT

Es p

er S

econ

d

MySQL Cluster Data Nodes

9thApril2015 Copyright2015,oracleand/oritsaffiliates.Allrightsreserved 38

Page 39: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.| 39

MySQLNDBCluster7.5

• ReadOpOmizedTables

• FullyReplicated

CapacityandScaleOut

• MySQL5.7• JSONDataType• GeneratedColumns• Records-Per-KeyOpOmizaOon

ImprovedSQL

• ImprovedReporOng• ImprovedLogging• ImprovedVisibility• ImprovedRestore

Management

RC

Page 40: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

• Readingfrombackupallowstoreadfromanycopy

• Previouslyallreadsweredirectedtowardstheprimaryfragmentonly

ConfidenOal–OracleInternal/Restricted/HighlyRestricted 40

MySQLNDB7.5:Readingfrombackup

NodeGroup

DataNode1 DataNode2

Page 41: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

NextStepsLearnMore•  www.mysql.com/cluster•  hxps://dev.mysql.com/doc/mysql-innodb-cluster/en/•  AuthenOcMySQLCurriculum:hxp://oracle.com/educaOon/mysql

TryitOut•  dev.mysql.com/downloads/cluster/7.4GAand7.5DMR1

•  hxps://labs.mysql.com/

Letusknowwhatyouthink•  hxp://mysqlhighavailability.com/•  forums.mysql.com/list.php?25

9thApril2015 Copyright2015,oracleand/oritsaffiliates.Allrightsreserved 41

Page 42: MySQL Clusters

Copyright©2016,Oracleand/oritsaffiliates.Allrightsreserved.|

Thankyou!