77
MySQL Cluster What's New & Best Prac0ces Copyright 2016, oracle and/or its affiliates. All rights reserved

MySQL Cluster Whats New

Embed Size (px)

Citation preview

MySQLClusterWhat'sNew&BestPrac0ces

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved

SafeHarborStatementThefollowingisintendedtooutlineourgeneralproductdirecGon.ItisintendedforinformaGonpurposesonly,andmaynotbeincorporatedintoanycontract.Itisnotacommitmenttodeliveranymaterial,code,orfuncGonality,andshouldnotberelieduponinmakingpurchasingdecisions.Thedevelopment,release,andGmingofanyfeaturesorfuncGonalitydescribedforOracle’sproductsremainsatthesolediscreGonofOracle.

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 2

MySQLClusterOverview• MemoryopGmizedtableswithdurability• PredictableLow-Latency,BoundedAccessTimeREAL-TIME

•  Auto-Sharding,MulG-Master•  ACIDCompliant,OLTP+Real-TimeAnalyGcs

HIGHSCALE,READS+WRITES

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

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

•  OpenSource+CommercialEdiGons•  Commodityhardware+Management,MonitoringToolsLOWTCO

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 3

MySQLReplica0on

MySQLFabric

DRBD

SolarisCluster,ClusterwareorOracleVM

MySQLCluster

MySQLHASoluGons

9 9 . 9 9 9 %

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 4

OracleMySQLHA&ScalingSoluGons

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 5

MySQLReplica0on MySQLFabric OracleVM OracleClusterware SolarisCluster MySQLCluster

AppAuto-Failover MySQLRouter ✔ ✔ ✔ ✔ ✔

DataLayerAuto-Failover MySQLRouter ✔ ✔ ✔ ✔ ✔

ZeroDataLoss MySQL5.7 MySQL5.7 ✔ ✔ ✔ ✔

PlaaormSupport All All All All Solaris All

ClusteringMode Master+Slaves Master+Slaves Ac0ve/Passive Ac0ve/Passive Ac0ve/Passive Mul0-Master

FailoverTime Secs Secs Secs+ Secs+ Secs+ <1Sec

Scale-out Reads ✔ ✖ ✖ ✖ ✔

Cross-shardoperaGons N/A ✖ N/A N/A N/A ✔

TransparentrouGng MySQLRouter ForHA ✔ ✔ ✔ ✔

SharedNothing ✔ ✔ ✖ ✖ ✖ ✔

StorageEngine InnoDB InnoDB InnoDB InnoDB InnoDB NDB

SingleVendorSupport ✔ ✔ ✔ ✔ ✔ ✔

Who’sUsingMySQLCluster?

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 6

CompanyOverviewPayPalallowsanybusinessorindividualwithanemailaddresstosecurely,conveniently,andcost-effecGvelysendandreceivepaymentsonline.Applica0on PayPalbuiltacloud-basedglobally-distributeddatabasewith100TBofuser-relateddatabasedonMySQLCluster.A“mustNOTlosedata”system,delivering99,999%availability,transacGonal,withdataavailableWWanywherein<1Sec.DetectsFraudwithin0.3seconds.Deployedover5datacentersworld-wide.WhyMySQLCluster?“Youcanachievehighperformanceandavailabilitywithoutgivinguprela8onalmodelsandreadconsistency.”--DanielAusGn,ChiefArchitect,PayPal

PayPal

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 7

CompanyOverviewWorld'slargestproducerofcasualgames.BigFishhasdistributedmorethan2.5billiongamestocustomersin150countries.Applica0onServereal-GmerecommendaGonstoBigFishcustomers,requiringhighvelocitydataingesGon,lowlatencyaccess,onlinescalability,99.999%availability,andEnterpriseSLAs.WhyMySQLClusterCGE?"TheMMSplaAormisastrategicprojectwithinBigFish.Wecouldn’taffordtotakeanychancesandMySQLClusterprovideduswithaprovenandtrustedsolu8ontomeetthedemandsofbothourbusinessandourusers.“--SeanChighizola,Sr.DirectorofDatabaseAdministraGon,BigFish

BigFish

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 8

CompanyOverviewGlobaltelecommunicaGonsequipmentcompany,focusesonfixed,mobile,andconvergednetworkinghardware,IPtechnologies,sopware,andservices.Applica0onMySQLClusterCGEisattheheartofAlcatel-Lucent’sSubscriberDataManagerusedtodeliverconvergedIMSservicestomobileandfixedlineusers.WhyMySQLClusterCGE?•  Deliverstheperformance,scalability,andavailability

requiredbythismissioncriGcalreal-GmeapplicaGon.•  Real-Gmeread&writeaccessfortensofmillionsof

subscriberswithinasinglesystem.•  Always-onservice:noofflinemaintenancewindowfor

servicesusersdependon(voice,SMS,email,Web,socialmedia,…)

•  Rapiddelivery&lowTCO

Alcatel-Lucent

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 9

SQL•  Industrystandard•  Joins&complexqueries• RelaGonalmodel

Memcached• SimpletouseAPI• Key/valuebased• Driversformanylanguages

Mod-ndb• RESTful•  JSONoverHTTP• PluginforApache

ClusterJ• SimpletouseJavaAPI• Web&Telco• ObjectRelaGonalMapping• NaGve&fastaccesstodata

ClusterJPA• OpenJPAplugin• StandardsdefinedORM• CrosstableJoins

JavaScript/Node.js• NaGveJavaScript:clienttoDB

• Blazingfastasynchronousthroughput

ChoosingtheRightClientAPI

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 10

MySQLClusterAuto-Installer

• FastconfiguraGon• Auto-discovery• WorkloadopGmized• RepeatablebestpracGces

SpecifyWorkload

Auto-Discover

DefineTopologyDeploy

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 11

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 12

NoSQLAccesstoMySQLClusterDataApps Apps Apps Apps Apps Apps Apps Apps Apps Apps Apps Apps

JPA

ClusterJPA

PHP Perl Python Ruby JDBC ClusterJ JS Apache Memcached

MySQL JNI Node.JS mod_ndb ndb_eng

NDBAPI(C++)

MySQLClusterDataNodes

13Copyright2016,oracleand/oritsaffiliates.Allrightsreserved

MySQLCluster7.4GA

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 14

MySQLCluster7.4GA

• 200MillionNoSQLReads/Sec

• 2.5MSQLOps/Sec• 50%FasterReads• 40%FasterMixedR/W

Performance

• AcGve-AcGveGeographicRedundancy

• MulG-DCClusters• ConflictDetecGon/ResoluGon

AcGve-AcGve

• 5xFasterMaintenanceOps

• DetailedReporGng

Management

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 15

• MemoryopGmizedtables– Durable– Mixwithdisk-basedtables

• MassivelyconcurrentOLTP• DistributedjoinsforanalyGcs• Parallelindexscans• Paralleltablescans(fornon-indexedsearches)

16

MySQLCluster7.4NoSQLPerformance200MillionNoSQLReads/Second

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved

!"!!!!

!50,000,000!!

!100,000,000!!

!150,000,000!!

!200,000,000!!

!250,000,000!!

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

Read

s&per&se

cond

&

Data&Nodes&

FlexAsync&Reads&

• MemoryopGmizedtables– Durable– Mixwithdisk-basedtables

• MassivelyconcurrentOLTP• DistributedjoinsforanalyGcs• Parallelindexscans• Paralleltablescans(fornon-indexedsearches)

17

MySQLCluster7.4SQLPerformance2.5MSQLStatements/Second

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved

!"!!!!

!500,000!!

!1,000,000!!

!1,500,000!!

!2,000,000!!

!2,500,000!!

!3,000,000!!

2! 4! 6! 8! 10! 12! 14! 16!

SQL$Statem

ents/sec$

Data$Nodes$

DBT2$SQL$Statements$per$Second$

Performance Enhancements MySQL Cluster 7.4

50%Read-OnlyIncrease

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 18

0"

1000"

2000"

3000"

4000"

5000"

6000"

7000"

8000"

9000"

64" 128" 192" 256" 320" 384" 448" 512"

Tran

sac'on

s)per)se

cond

)

Threads)

Sysbench)R/W)

7.4"

7.3"

7.2"

0"

1000"

2000"

3000"

4000"

5000"

6000"

7000"

8000"

9000"

10000"

64" 128" 192" 256" 320" 384" 448" 512"

Tran

sac'on

)per)se

cond

)

Threads)

Sysbench)RO)

7.4"

7.3"

7.2"

40%Read/WriteIncrease

• AsynchronousreplicaGonbetweenMySQLClusters

• AcGve-AcGveMulG-Homed– Updateanywhere– ConflictdetecGon

•  ApplicaGonnoGfiedthroughexcepGontables•  CanopttohaveconflictsresolvedautomaGcally

– AutomaGcconflictresoluGon•  ConflicGngtransacGonanddependentonesarerolled-back

• NochangestoapplicaGon/schema

AcGve-AcGveGeo-ReplicaGon

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 19

WhatIsaConflict?

John.balance==$100

John.balance-=$40John.balance==$60

John.balance==$200

John.balance==$100

John.balance+=$100John.balance==$200

John.balance==$60

Spend$40 Add$100

$60$200

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 20

• NDB$EPOCH2andNDB$EPOCH2_TRANSintroduced

• DetectsconflicGnginserts/updates/deletes/reads

•  EnGretransacGons(anddependentones)rolledback

• RollingbackoftransacGonsthatreadconflicteddata

•  ImprovedNDBExcepGonstableformat– Non-PKcolumns,operaGontype,transacGonid,beforeandapervalues

• Onlineconflictrolechange

21

HandlingofConflicts–ExtensionsinMySQLCluster7.4

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved

•  PrimarystoreslogicalGmestamp(GCI)againstupdatedrow(s)– Windowforconflictopens

•  GCIisreplicatedwithupdatedrow(s)toSecondary

•  ThesameGCIisreplicatedback(reflected)fromSecondarytoPrimaryaperithasbeenapplied–  Closingwindowforconflict

•  PrimarycheckseveryeventoriginaGngfromtheSecondarytocheckforconflicts

DetecGngConflicts-ReflectedGCI

John.balance==$100

John.balance-=$40John.balance==$60

John.balance==$200

John.balance==$100

John.balance+=$100John.balance==$200

John.balance==$60

Spend$40 Add$100

$60$200

Primary Secondary

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 22

HowtoUseConflictDetecGonandResoluGon

DecidewhichtablesneedprotecGng

Foreachtable,specifywhattodoonconflicts

RecordeventinexcepGontable

ApplicaGonorDBAcanacton

content

RollbacktheconflicGngrow

RollbacktheconflicGngtransacGon

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 23

MySQLCluster7.4RestartImprovements

• DuraGonoflong-runningmaintenanceacGviGesdominatedbyDataNoderestartGmes

• MySQLCluster7.4=5.5xfasterrestarts!• Benefitsanykindofnoderestart

– Upgrades,add-node,…• Benefitsboth”manual”andMySQLClusterManageroperaGons• Accomplish5xasmuchworkduringasinglemaintenancewindow

MakeDataNodeRestartsFast!

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 24

MySQLCluster7.4RestartImprovements

• Verboselogging– TaskstartandcompleGon– Datavolumeinfo– Parallelism&waitGmeinfo

• NDBINFOforrecentnoderestarts• MoredocumentaGonofconcretestages• Goal:makeproperanalysisofaslowrestarteasy

– Determinecause;Detectpa}erns;Understandtheimpactofindexes,localcheckpoints,etc.

ObservabilityImprovements

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 25

MySQLCluster7.4–EnhancedMemoryReporGng• ndbinfo.memory_per_fragmentmemoryusageinformaGonforeachfragmentreplica,foreachtable,andeachindex

• Allocatedmemory,andhowmuchofthatisactuallyinuse•  Exposes

– FragmentaGonoffixedandvariablesizedfragmentpages– AccurateDataandIndexMemoryuse– ComparisonofPrimaryandBackupfragmentusage– ParGGon/SharddistribuGonandeffecGveness

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 26

EnhancedMemoryReporGng

mysql>CREATETABLEsimples(idINTNOTNULLAUTO_INCREMENTPRIMARYKEY)ENGINE=NDB;mysql>SELECTnode_idASnode,fragment_numASfrag,fixed_elem_alloc_bytesASalloc_bytes,fixed_elem_free_bytesASfree_bytes,fixed_elem_free_rowsASspare_rowsFROMmemory_per_fragmentWHEREfq_nameLIKE'%simples%';+------+------+-------------+------------+------------+|node|frag|alloc_bytes|free_bytes|spare_rows|+------+------+-------------+------------+------------+|1|0|131072|5504|172||1|2|131072|1280|40||2|0|131072|5504|172||2|2|131072|1280|40||3|1|131072|3104|97||3|3|131072|4256|133||4|1|131072|3104|97||4|3|131072|4256|133|+------+------+-------------+------------+------------+

SeeHowMuchMemoryaTableisUsing

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 27

EnhancedMemoryReporGng

+------+------+-------------+------------+------------+|node|frag|alloc_bytes|free_bytes|spare_rows|+------+------+-------------+------------+------------+|1|0|131072|5504|172||1|2|131072|1280|40||2|0|131072|5504|172||2|2|131072|1280|40||3|1|131072|3104|97||3|3|131072|4256|133||4|1|131072|3104|97||4|3|131072|4256|133|+------+------+-------------+------------+------------+mysql>DELETEFROMclusterdb.simplesLIMIT1;+------+------+-------------+------------+------------+|node|frag|alloc_bytes|free_bytes|spare_rows|+------+------+-------------+------------+------------+|1|0|131072|5504|172||1|2|131072|1312|41||2|0|131072|5504|172||2|2|131072|1312|41||3|1|131072|3104|97||3|3|131072|4288|134||4|1|131072|3104|97||4|3|131072|4288|134|+------+------+-------------+------------+------------+

SeeHowMemoryisMadeAvailableA_erDele0ngRows

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 28

EnhancedMemoryReporGng

mysql>CREATETABLEsimples(idINTNOTNULLAUTO_INCREMENT,speciesVARCHAR(20)DEFAULT"Human",PRIMARYKEY(id,species))engine=ndbPARTITIONBYKEY(species);//Addsomedatamysql>SELECTnode_idASnode,fragment_numASfrag,fixed_elem_alloc_bytesASalloc_bytes,fixed_elem_free_bytesASfree_bytes,fixed_elem_free_rowsASspare_rowsFROMndbinfo.memory_per_fragmentWHEREfq_nameLIKE'%simples%';+------+------+-------------+------------+------------+|node|frag|alloc_bytes|free_bytes|spare_rows|+------+------+-------------+------------+------------+|1|0|0|0|0||1|2|196608|11732|419||2|0|0|0|0||2|2|196608|11732|419||3|1|0|0|0||3|3|0|0|0||4|1|0|0|0||4|3|0|0|0|+------+------+-------------+------------+------------+

CheckPar00on/ShardDistribu0onandEffec0veness

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 29

MySQLCluster7.4–EnhancedAcGvityReporGng• ndbinfo.operations_per_fragment acGvitycountersforeachfragmentreplica,foreachtable,andeachindex

• PKbasedandscanaccesses–requests,bytes,rows,…•  Exposes

– HowSQLstatementsmaptoindividualtablesandindices– QueryexecuGon,useofindexesetc.– LDMandnodeimbalances– Hotspotsandscanoverloads

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 30

MySQLCluster7.5• BasedonMySQL5.7

– NaGveJSONdatatype– GeneratedColumns

•  FuncGonBasedIndexes– CostBasedOpGmizer– NewSpaGalengine– NewhintsyntaxwithaddiGonalhints– MemoryinstrumentaGon– Securebydefault– Muchmore!

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 31

NEW!

MySQLCluster7.5• ConGnueImprovingSupportability

– OverloadcontrolsviathreadidlewaitGme– ImproveeventbuffermemoryallocaGon– Be}erandmoredescripGveerrormessages– Dumpcommandimprovements– ImprovedLockreporGng

• ConGnueImprovingPerformance– Fasterbackup&restore

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 32

NEW!

MySQLCluster7.5• ConGnueImprovingAvailability

– Convertndb_binlog_indextoACIDstorage– Makeuseofdynamiccolumnseverywhere

•  SupportforonlinedefragmentaGonandspacereclamaGon•  SupportforrowtransformaGons–encrypGonandcompression

• ConGnueImprovingQuality– Refactorbinloginjectorinordertoaddressmanyknownissues– Increasethetestbase– MoresystemcorrectnessandfaultinjecGontests

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 33

NEW!

MySQLCluster7.5• ConGnueImprovingCapacity

– Enableindividualfragmentslargerthan16GB(nowupto128TB)

•  ImprovedReadScale-Out– TheintroducGonof“readfrombackup”fortables

•  Localizedreadsoneverynodeinanodegroup– TheintroducGonof“global”tables(fullyreplicated)

•  LocalizedreadsoneverynodeintheCluster

•  SupportforIncreasedRedundancy– Supportforupto4nodespernodegroup(1-3replicaspershard)

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 34

NEW!

MySQLClusterBestPracGces

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 35

When to Consider MySQL Cluster l  UpGmerequirements

l  CostperminuteofdownGme?l  Failureversusmaintenance?

l  Scalabilitydemandsl  Shardingforwritescaling?

l  Latencydemandsl  Costofeachmillisecond?

l  ApplicaGonagilityl  Developerlanguagesandframeworks?l  SQLandNoSQL?

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 36

General Usage Considerations •  MySQL Cluster is designed for

–  Short transactions –  Single key reads and writes – Many parallel transactions

•  Utilize simple access patterns for high running transactions – Use efficient scans and batching interfaces –  Push down joins yield huge performance improvements for JOIN operations – MySQL Cluster 7.4 speeds up table scans

•  Storage Engine is configurable for each table…InnoDB or NDB

MySQLClusterEvaluaGonGuideh}p://mysql.com/why-mysql/white-papers/mysql_cluster_eval_guide.php

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 37

D1 D2 D3 D4

API ---------- ---------- ----------

TC TC TC TC

1

2

AccessingData:PKLookups

•  SingleTransacGonCoordinator(TC),noaddiGonaldatadistribuGonhandling

•  FirststatementdecidesTC• KeeptransacGonsshort!

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 38

D1 D2 D3 D4

API ---------- ---------- ----------

TC TC TC TC

1

2

3

Accessingdata:UniqueSecondaryKeyLookups

•  Secondarykeysimplementedashidden/systemtables

• HiddentableshavenewsecondarykeyasPKandbasetable’sPKasvalue

• Datamayresideonsamenodeorothernode

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 39

D1 D2 D3 D4

API ---------- ---------- ----------

TC TC TC TC

1 3

2

Accessingdata:RangeScansandJoins

•  TCischosenusinground-robin

• DatanodesreturndatadirectlytoAPI

•  Flow:– Choosedatanode– SendrequesttoallLDM– SenddatatoAPI

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 40

SELECT SUM(population) FROM towns WHERE country=“UK”;

SELECT SUM(population) FROM towns WHERE town=“Boston”;

• ParGGonselectedusinghashonspecifiedParGGonKey– PrimaryKeybydefault– UsercanoverrideintabledefiniGon

• MySQLServer(orNDBAPI)willa}empttosendtransacGontothecorrectdatanode– IfalldataforthetransacGonareinthesameparGGon,lessmessaging->be}erscalability

• Aimtohaveallrowsforhigh-runningqueriesinsameparGGon

DistribuGonAwareApps

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 41

•  ExtendparGGonawarenessovermulGpletables

•  Samerule–aimtohavealldataforinstanceofhighrunningtransacGonsinthesameparGGon

– ALTER TABLE service_ids PARTITION BY KEY(sub_id);

DistribuGonAware–MulGpleTables

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 42

FasterJoins–PushdownJoins

• AcGvatedwhenndb_join_pushdownison(default)• Rulesforajointobepusheddown:

1.  JoinedcolumnsuseidenGcaltypes2.  NoreferencetoBLOBorTEXTcolumns3.  Noexplicitlock4.  ChildtablesintheJoinmustbeaccessedusingref,eq_ref,orconst5.  TablesnotexplicitlyparGGonedby[LINEAR] HASH,LIST,orRANGE6.  QueryexecuGonplandoesn’tusemysqld’sinternal‘join buffer'7.  Ifrootofjoinisoftheeq_reforconst type,childtablesmustbejoinedbyeq_ref

• RunANALYZE TABLE <table_name> oneachtableonce• UseEXPLAINtoseewhatcomponentsarebeingpusheddown:

– For example: Extra: Child of 'd' in pushed join@1

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 43

GlobalCheckpointsandLogging• GlobalCheckpointProtocol/GroupCommit(GCP)– REDOlog,synchronizedbetweentheDataNodes

– WritestransacGonsthathavebeenrecordedintheREDOlogbuffertoREDOlogondisk

– FrequencycontrolledbyTimebetweenGlobalCheckpoints•  Defaultis2000ms

– SizeoftheREDOlogissetusingNumOfFragmentLogFiles

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 44

LocalCheckpointsandLogging•  LocalCheckpointProtocol(LCP)

– FlushestheDataNodes’datatodisk.Aper2LCPstheREDOlogistrimmed

– FrequencycontrolledbyTimebetweenLocalCheckpoints•  Specifiestheamountofdatathatcanchangebeforeflushingtodisk

•  NotactuallyGme!Base-2logarithmofthenumberof4-bytewords

•  Example:Defaultvalueof20bytesmeans4*2^20=4MBofdatachanges

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 45

CheckpointsandLoggingLocal&Redo

•  LCPandREDOLogareusedtobringtheclusterbackonline– Followingsystemfailureorplannedshutdown1.  DataNodesarerestoredusingthe

latestLCP2.  REDOlogsareappliedunGlthe

latestGCP

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 46

MySQLClusterHardwareRequirements•  TCP/IPorInfiniband

– Minimum100Mbps,1Gbpsorhigherrecommended– MySQLClusterdedicatednetwork:separateDataNodesfromMySQLServers

• Homogeneousenvironmentsforeachlayer:APInodes&DataNodes• Machines

– Linux,Solaris,Windows,OSX•  h}ps://www.mysql.com/support/supportedplaaorms/cluster.html

– Min.1GbRAM– CPU,RAM,DISK:“themoreandfaster,thebe}er”

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 47

MySQLClusterHardwareSelecGon

•  4-24x86_64bitCPUthreads(vCPUs)• Minimum4GBofRAM

– MemorynotascriGcalatthislayer– RequirementsinfluencedbyconnecGonsandbuffers

•  2NetworkInterfaceCards(NICs)•  2PowerSupplyUnits(PSUs)•  Linux,Solaris,Windows,orOSXoperaGngsystem

MySQLServers

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 48

MySQLClusterHardwareSelecGon

•  Upto64x86_64bitCPUthreads(vCPUs)–  Highfrequency:enablesfasterprocessingofmessages

•  CalculaGngRAMperDataNode(in-memorydatabase)–  DatabaseSize*#Replicas*1.25/#datanodes–  50GBdatabase*2replicas*1.25/2datanodes=64GBofRAM–  Non-indexedcolumnscanbestoredondisk,reducesRAMrequirements

•  2NICsand2PSUs•  Deep-diveintonetworkbest-pracGcesinReferenceArchitectureGuide•  UseMaxNoOfExecutionThreadsorThreadConfigtoconfigurehowthreadsshouldbeallocated

DataNodes

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 49

Entry-Level Mid-Range High-End

1xSATA7200RPM• Forread-mostly• Noredundancy(butotherdatanodeisthemirror)

1xSAS10KRPMorSSD• Heavyduty(manyMB/s)• Noredundancy(butotherdatanodeisthemirror)

4xSAS10-15KRPMorSSDs• Heavyduty(manyMB/s)• Diskredundancy(RAID1+0/10),hotswappable

LCP/REDOLOG

MySQLClusterHardwareSelecGon

•  REDO,LCP,BACKUP–wri}ensequenGallyinsmallchunks(256KB)•  Ifpossible,useODirect=1

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 50

DiskSubsystemforCheckpoin0ng

LCP/REDOLOGLCP/REDOLOG

RecommendedMinimum High-EndRecommendaGon

2xSAS10KRPMor2xSSD

TABLESPACE

LCPREDOLOGUNDOLOG

UNDOLOG

LCP(REDOLOG/UNDOLOG)

TABLESPACE1

TABLESPACE2

4xSAS10-15KRPMorSSD

(REDOLOG)(REDOLOG)

MySQLClusterHardwareSelecGon:

•  UseHigh-EndRecommendaGonforheavyread/writeworkloads•  HavingTABLESPACEonseparatediskisgoodforreadperformance•  EnableWRITE_CACHEonblockstoragedevices

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 51

DiskBasedTables

ZoneBZoneA

LocaGonofNodes

• Minorityofdatanodeslost– Isolatedminoritywillshutdown

• Majoritypool(>50%ofthedatanodesandonefromeachNodeGroup)– Remainsviable– ExcludefailednodesfromclusteroperaGons

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 52

HandlingNetworkPar00ons

NodeGroup1

NodeGroup2

ZoneBZoneA

LocaGonofNodes

• NetworkconnecGvitylostbetweenzones

•  Eachpoolhas50%ofdatanodesand1fromeachNodeGroup– Eachviable,butZoneswilldivergeiftheybothlive(split-brain)

– Sowholivesonandwhodies?– WeneedarbitraGon

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 53

HandlingNetworkPar00ons

NodeGroup1

NodeGroup2

ZoneBZoneA

LocaGonofNodes

• Arbitratordecides– Contactedbydatanodesfromeachzone– Tellsthoseinonezonetoshutdown– Tellsthoseinotherzonetostayup

• Vitalthatarbitratorsharesnosinglepointoffailurewitheitheravailabilityzone

• Defaultarbitratorisanndb_mgmd nodebutcanalsobeamysqld node

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 54

AvoidingSplit-BrainDuringNetworkPar00ons

NodeGroup1

NodeGroup2

ZoneC

Arbitrator

Spli�ngMySQLClusterOverMulGpleSites

•  Thegreaterthelatencybetweensites,thehighertheimpactonperformance

•  Targetlatencyshouldbe<=10ms;20msacceptable– Testatthenetworklayerwith1000bytepacketsunderload

• Bandwidthrequirementsdependentontrafficbutaimfor1Gbps+(100MbpsforalowtrafficCluster)

•  SimplestWANtopologypossible(fewerpointsoffailure/failoverlatency)•  TypicalWANfailoverGmesshouldbeshortenoughnottotriggerSTONITHacGviGeswithinCluster

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 55

WANEngineering

• AsynchronousreplicaGonbetweenMySQLClusters

• AcGve-AcGveMulG-Homed– Updateanywhere– ConflictdetecGon

•  ApplicaGonnoGfiedthroughexcepGontables•  CanopttohaveconflictsresolvedautomaGcally

– AutomaGcconflictresoluGon•  ConflicGngtransacGonanddependentonesarerolled-back

• NochangestoapplicaGon/schema

AcGve-AcGveGeo-ReplicaGon(Reminder)

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 56

MySQLClusterGeographicReplicaGon

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 57

Implementa0on

MySQLClusterGeographicReplicaGon

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 58

Scenariosforreplica0ngbetweenclusters

• ParGGoncustomersacrossmulGpleclusters,distributedbyregiontoopGmizelowlatencyaccess

•  Eachsub-clusterisreplicatedforHighAvailability

• AcGve/passiveorAcGve/AcGve

59

GeographicReplicaGonforLow-LatencyLocalAccess

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved

Cluster4

Cluster1

Cluster1B

Cluster1CCluster2

Cluster2B

Cluster2C

Cluster3

Cluster3B

Cluster3C

Cluster4C

Cluster4B

MySQLClusterBackups•  BackupofNDBtables

–  Online–canhaveongoingtransacGons–  Consistent–onlycommi}eddataandchangesarebackedup

•  ndb_mgm -e "START BACKUP" –  CopybackupfilesfromdatanodestosafepersistentlocaGon

–  Non-NDBtablesmustbebackedupseparately– MySQLsystemtablesarestoredinMyISAMorInnoDB

•  Youwanttobackup(foreachMySQLServer)–  mysqldatabase/schema–  Triggers,rouGnes,events,...

•  Usemysqldump–  mysqldump mysql > mysql.sql –  mysqldump --no-data -A > schemas.sql

–  mysqldump --no-data --no-create-info -R > routines.sql

•  Copymy.cnf&config.inifiles

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 60

MySQLClusterBackups

mcm>backupclustermycluster;mcm>listbackupsmycluster;mcm>restorecluster-I<backup-id>mycluster

UsingMySQLClusterManager

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 61

FeaturestoUseWithCauGon

•  LargeBLOBs• Diskbasedtables•  EnforcedForeignKeys•  Largerangescansandjoins•  Spli�ngasingleMySQLClusterovermulGpledatacenters• AcGve-AcGveGeographicReplicaGon

– FinetousebutbestifconflictscanbeavoidedontheapplicaGonside

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 62

Poten0alImpactstoPerformance,Capacity,&Stability

Machine1

TypicalArchitectures

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 63

Enterprise-MinimalHAConfigura0on

MySQLServer

DataNode

App

Machine2

MySQLServer

DataNode

App

Machine3

MgmtNode

Machine4Machine3

Machine1

TypicalArchitectures

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 64

Enterprise-Small

MySQLServer

DataNode

App

Machine2

MySQLServer

DataNode

App

MgmtNode

MgmtNode

Machine4Machine3

Machine1

TypicalArchitectures

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 65

Enterprise-Scale-out

MySQLServer

DataNode

App

Machine2

MySQLServer

DataNode

App

MgmtNode

MgmtNode

Machine8Machine7

Machine5

25/10/17

MySQLServer

DataNode

App

Machine6

MySQLServer

DataNode

App

Machine9

MySQLServer

App

MySQLServer

App

TypicalArchitectures

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 66

Telco/Gaming

DataNode

App

DataNode

App

MgmtNode

MgmtNode

25/10/17

DataNode

App

MySQLServer

DataNode

App

MySQLServer

TypicalArchitectures

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 67

Telco/Gaming

DataNode

App

DataNode

App

MgmtNode

MgmtNode

25/10/17

DataNode

App

MySQLServer

DataNode

App

MySQLServer

DataNode

App

DataNode

App

‘Typical’Architectures

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 68

Telco/Gaming-scale

25/10/17

Site2Site1

‘Typical’Architectures

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 69

Telco/Gaming–GeographicReplica0on

25/10/17

MySQLClusterSupport

IssueDetected

SRCreated

SupportWorksonSR

IfBug

BugReportOpened

BPS(priority)SetBasedonSRFields

BugFixCreated

HotFix? MaintenanceRelease

IfNotBug

SupportRespondstoCustomerViaSR

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 70

MySQLClusterCGE

MySQLClusterManager

MySQLEnterpriseScalability

MySQLEnterpriseAudit

MySQLEnterpriseSecurity

OraclePremierLifeGmeSupport

OracleProduct

CerGficaGons

MySQLEnterpriseMonitor

MySQLWorkbench

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 71

EnhancingDevOpsAgility,ReducingDownGme

AutomatedManagement

•  Start/stopnodeorenGrecluster

• On-Linescaling• On-LinereconfiguraGon• On-Lineupgrades• On-Linebackup&restore

•  ImportrunningCluster

Self-Healing

• Nodemonitoring• Auto-recoveryextendedtoSQLandmgmtnodes

HAOperaGons

• Cluster-wideconfiguraGonconsistency

• PersistentconfiguraGons

• HAagents

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 72

WithoutMySQLClusterManager•  1xpreliminarycheckofclusterstate•  8xsshcommandsperserver•  8xper-processstopcommands•  4xscpofconfigfiles(2xmgmd&2xmysqld)•  8xper-processstartcommands•  8xchecksforstartedandre-joinedprocesses•  8xprocesscompleGonverificaGons•  1xverifycompleGonofthewholecluster•  ExcludesmanualediGngofeachconfiguraGonfile

•  Total:46commands– 2.5hoursofaNendedopera8on

WithMySQLClusterManager

mcm> upgrade cluster --package=7.4 mycluster;

•  Total:1Command

– UnaNendedOpera8on

SopwareUpgrade–ExampleofMCMBenefits

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 73

MySQLClusterManager1.3GA

“Unmanaged”producGonCluster

mcm> create cluster --import

mcm> import config [--dryrun]

mcm> import cluster [--dryrun]

ClusternowmanagedbyMCM

ImportarunningClusterintoMCM

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 74

MySQLClusterManager1.4GAAutotuneYourCluster

Copyright2016,oracleand/oritsaffiliates.Allrightsreserved 75

mcm>autotune--writeload=highrealtimemycluster;+-----------------------------------------------------+|Commandresult|+-----------------------------------------------------+|Clustersuccessfullyautotunedtotemplaterealtime|+-----------------------------------------------------+1rowinset(2min58.09sec)

MySQLEnterpriseMonitor

76Copyright2016,oracleand/oritsaffiliates.Allrightsreserved

MySQLEnterpriseMonitor

77Copyright2016,oracleand/oritsaffiliates.Allrightsreserved