47
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | TRN4032: High Availability and Sharding Deep Dive with Next Generation Oracle Database Wei Hu Vice President, Product Development High Availability Technologies October 22, 2018 Confidential – Oracle Internal/Restricted/Highly Restricted

High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

TRN4032:HighAvailabilityandSharding DeepDivewithNextGenerationOracleDatabase

WeiHuVicePresident,ProductDevelopmentHighAvailability TechnologiesOctober22,2018

Confidential– OracleInternal/Restricted/HighlyRestricted

Page 2: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

SafeHarborStatement

Thefollowingisintended tooutline ourgeneralproductdirection. Itisintended forinformationpurposes only,andmaynotbe incorporatedintoanycontract.Itisnotacommitment todeliver anymaterial,code,orfunctionality,andshouldnotberelieduponinmakingpurchasingdecisions. Thedevelopment, release, timing, andpricingofanyfeaturesorfunctionality described forOracle’sproductsmaychangeandremainsatthesolediscretion ofOracleCorporation.

Confidential– OracleInternal/Restricted/HighlyRestricted

Page 3: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

Amazon.comrunsOracle• AmazonPaymentsPlatformrunsonOracle

– eCommerce paymentssystemsupportingmillionsofAmazoncustomers

• AmazonRetailSystemsrunonOracle– MultiplelargedatabasessupportingOLTPandDSS

• AmazonDigitalCommercePlatformrunsOracle– Supports theservicesbehindtheKindleandotherAmazondigitalbusinesses

• Processpaymentsatanunprecedentedscale,withaccuracy,speed,andmission-criticalavailability – Amazon.comquote

• Amazonspends$60millionwithOracle – LarryEllison,OOW2017

3

Page 4: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

WhydoesAmazon.comuseOracle?• AmazontellstheircustomerstouseAurora,Redshift,Postgres,andMySQL• ButthesedatabasesarenotgoodenoughforAmazon.com

– NoRAC,noActiveDataGuard,noReal-Application Testing,…

• Importanttake-away:– YoucanmodifyanapplicationwrittentoOracletorun onotherdatabases– ButonlyOraclecanrunapplications attheavailability,andsecuritythatAmazon.com(andothercustomers) require

– Also,unlikeAmazon’sdatabases (Aurora,Redshift), Oracleisavailable on-premisesandinthecloud(includingAWS)

• ThissessionwilltalkabouttheOracleavailabilityfeaturesthatcustomerslikeAmazon.comrelyontokeeptheirapplicationsrunning24x7

4

Page 5: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

Edition-based Redefinition,Online Redefinition, DataGuard,GoldenGate–Minimaldowntimemaintenance,upgrades,migrations

ActiveDataGuard– DataProtection,DisasterRecovery– QueryOffload

GoldenGate– Active-activereplication– Heterogeneous

ActiveReplica

RMAN,OracleSecureBackup,ZeroDataLoss RecoveryAppliance

– Backuptodisk,tapeorcloud

Enterprise ManagerCloud Control– SiteGuard,CoordinatedSiteFailoverApplication Continuity– ApplicationHAGlobalDataServices– ServiceFailover/LoadBalancing

RAC– Scalability– ServerHA

ASM– Localstorage

protection

ProductionSite

Flashback– Humanerror

correction

OracleMaximumAvailabilityArchitecture(MAA)

5

Sharding– HorizontalPartitioning,

Scalability,SharedNothingarchitecture

Page 6: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

ProgramAgenda

ActiveDataGuard

Sharding

GloballyDistributedDatabase

PlannedDowntime

AutonomousDatabaseandCloud

1

2

3

4

5

Confidential– OracleInternal/Restricted/HighlyRestricted 6

Page 7: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

ActiveDataGuardisCriticalPartofMAA

• Automaticfailoverincaseofsitefailure(usingFast-StartFailover)– Humaninvolvementwillslowfailovertime(increase RTO)

• Protectsagainstdataandstoragecorruptions• Automaticallyrepairsblockcorruptions• Active-active architectureautomaticallyensuresthatstandbyisfunctioningandfailover-ready

• Minimumdowntimerollingupgrades(usingtransientlogicalstandby)

7

Page 8: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

ActiveDataGuardfeaturesin12.1and12.2• ZeroDataLoss

– FarSyncsupports zerodatalossoverlongdistances– FastSyncsupports low-latencycommitsforzerodataloss– Real-timeCascadesupports near-zerodatalossevenforcascadedconfigurations

• Active Standby– In-memoryDBonActiveDataGuardallowsin-memorytablesonthestandby– Diagnosticandtuningpack(AWR),SQLPlanManagement onActiveDataGuard– GlobalTemporaryTables onActiveDataGuard– GlobalDataServicesloadbalancesconnections amongprimaryandActiveDataGuardinstances

• FastFailover– Preservesessions onActiveDataGuardduringfailoverorswitchover– Multi-instanceparallelredoapply usesallinstancesinaRACstandbytoapplyredo

• …andmore…8

Production

ActiveDataGuard

FarSync

Page 9: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

ActiveDataGuardfeaturesinOracleDatabase18c

• Fast,automaticnologging loadswithActiveDataGuard– Customersusenologging loadstoavoidoverheadofgeneratingredo– InOracle18c,theprimaryshipsdatablockstothestandbyasblocksareloadedtotheprimary

– AvailableonEngineeredSystemsandOracleCloud• DataGuardBrokerprovidesvalidationandproactivehealthchecks.UsedbyOracleCloudtodetectandfixproblems beforetheyoccur

• CREATE GLOBAL TEMPORARY TABLE onActiveDataGuard– ActiveDataGuard12ccanupdateglobaltemporarytables,butthetablesstillneededtobecreatedattheprimary.In18c,thestandbycancreateitsowntemporarytables

9

Production

ActiveDataGuard

Page 10: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

ActiveDataGuardFeaturesinOracleDatabase18c

• Automatically updatepasswordfileonstandbys(12.2)– ChangingAdminpasswordonprimaryautomatically updatesstandbys’

• Zero-downtime,Standby-first,encryption– Firstencrypttablespaces onstandby,switchover,thenencryptontheoldprimary

• NewDGredoauthentication protocol- usesSSLcertificate for‘redo_transport_user’

• Trackloginfailuresacrossalldatabases inaDataGuardconfiguration.Loginsanywherewillbedeniedwhenthemaxlogincountisreached

SimplifyingSecurityManagementforYourDataGuardConfiguration

Page 11: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

UpdatesonActiveDataGuardusingDMLRedirection• Previously,youcanonlyupdateGlobalTempTablesonActiveDataGuard.With19c,youcanupdateregulartables

• UpdatesonActiveDataGuard:1. Updatewillbe redirected tothe primary2. Primarymakes update, generates&sends redo forthatupdate toall

standbys3. ActiveDataGuard session sees theupdate in redoapply andresumes

• PreservesACIDpropertiesforADGsession– Redirectedupdate only visible tosession before commit; visible toall

sessions aftercommit

• For“MostlyRead,OccasionalUpdates”applications– forexample,recordinguserloginsforauditingpurposes

• EnabledbyADG_REDIRECT_DML atsystemorsessionlevel

11

UpdateX

ActiveDataGuardPrimary

Page 12: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

ProgramAgenda

ActiveDataGuard

Sharding

GloballyDistributedDatabase

PlannedDowntime

AutonomousDatabaseandCloud

1

2

3

4

5

Confidential– OracleInternal/Restricted/HighlyRestricted 12

Page 13: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

• Dataautomaticallypartitionedacrosspoolofindependentdatabases(shards)

• Addshardsonlinetoincreasethroughput• Data,usersandtransactionsscalelinearly• Single- andmulti-shardqueries

• Outageorslowdownofashardhasnoimpactonavailabilityofothershards

• Shard-levelHAautomaticallyconfiguredusingdatabasereplication(RACoptional)

• Shardscanbeindependentlypatchedandupgradedwithoutaffectingothershards

• Flexibleshardorganization- consistenthash,range,list,orcomposite(range-hash,list-hash)

• Dataplacementforavailability,disasterrecovery,performance,ortomeetregulatoryrequirements

13

RACandDataGuardmeetneedsofmostapplicationswhilepreservingapplicationtransparencySomelargescaleapplicationswanttoshardacrossfarmofindependent databasesandarewillingtomodifyapplication

OracleDatabaseSharding

LinearScalability FaultTolerant GeographicDistribution

Page 14: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

OracleProvidesContinuumofShared-DiskandShared-Nothing

• Shared-DiskandShared-Nothinghavetheirrespectivestrengths• Applicationtransparencyvseasyscalabilityandfaultisolation

– SAPvsiCloud• Mostdatabasesonlysupportshared-nothingbecauseshared-disk(RAC)ishard

• Oracleoffersbothendsofthespectrum(RACandSharding)• 18c introducesmid-pointarchitecturethatprovidesinterestingcapabilities– RACSharding

OracleRestricted 14

Shared-Disk Shared-Nothing

Complex schema,complex access pattern

Simple schema,Key-based access pattern

Page 15: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

RACSharding

• Affinitizes shardstoRACinstances– Requeststhatspecifysharding keywillberoutedtothe

RACinstancethatlogicallyholdstheshard– Bettercacheutilizationandreducedblockpingsacross

instances

• Requests thatdon’tspecifysharding keystillworktransparently

• GivesSharded Databaseperformancewithminimalapplication changes– Justaddsharding keytothemostperformanceintensiveoperations

• AvailableonEngineered SystemsandOracleCloud

15

OracleRACDatabase

Higherperformanceforshard-awareRACapplications

Page 16: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

OracleSharding | 19cFeatures• SupportmultiplePDB-shardsinthesameCDB

– APDBcanbesharded acrossmultiple CDBs– Allowsconsolidation ofsharded databases

• Scale-outmulti-shardquerycoordinators– Canconfigureshardcatalog's ADGstandbystoactasmulti-shard querycoordinators– Greatforanalyticworkloadsthatneedtoquerymultiple shards

• MultipleTableFamilies– Allowsasharded database tosupportmultiple tablefamilies, eachofwhichcanbeshardedwithadifferentshardingkey

• Generationofgloballyuniquesequencenumbersacrossshards– Fornon-primarykeycolumns (e.g.order_id)

Page 17: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Oracle Sharding POC

@ State Grid Corporation of China

Page 18: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

• Largestelectricutilityintheworld• Providespowertoover1.1billionpeople across88%ofChina• Globalpresencewithsubsidiaries inPhilippines, Brazil,Portugal,AustraliaandItaly

• 1.72million employees, $585billion inassets, $348.9billion revenue(2017)• Ranked#2inFortuneGlobal500(2nd largestcompanygloballybyrevenue)

• Companymission• Asasuper-largestate-owned enterprise crucialtonational energysecurityandeconomic lifeline, SGCChasamission toprovidesafer,cleaner,andmoreeconomical andsustainable powersupply

State Grid Corporation of China (SGCC)

Page 19: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

• SGCCisadoptingMicroservice architecture forthegrowingbusiness• Microservice architectureprovidesresiliencythroughloosecouplingandflexibilitytomeetgrowingandchangingbusinessneeds

• Microservice architecture inturnrequiresahighlyscalable,loosely-coupled,andultra-reliable distributeddatabase

• StateGridwanted toprovethattheirbusiness-critical orderingservice systemcanleverage OracleSharding tomeetthese requirements

• Orderingservicecurrentlyhas200-300millionusersdistributedacross26subsidiaries.Goalistobuildcentralizedorderingservice

• Tominimizetheimpactontheirdevelopment processes, thenewdistributeddatabasemustsupport their currentdevelopment frameworkbasedonSpring+Mybatis

Challenges

Page 20: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

• Schemasharded usingOrderNumber• ClientusesSpring-MyBatis JavapersistenceframeworkusingOracleUCPasDataSource

• ToavoidmodifyingMyBatis sourcecode,localthreadwasaddedtopasstheSharding keyfromControllertotheUCPDataSourcedirectly–allowinghighperformancedirectaccesstoshards

Architecture

Page 21: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

• Successfully leveragedOracleSharding inSpring+MyBatis Frameworkwithoutmodifyinganyapplicationcode

• Goodexample forhowtointegrateShardingAPIintoJavapersistence frameworks ingeneral

• Inthefuture, Oracleuser-defined Sharding alsoallowsdatatobestoredclosetoStateGrid’s customersdistributed indifferent locations

• OracleSharding provides thehighlyscalable, loosely-coupled, andultrareliabledistributeddatabase requiredbynewgenerationmicroservice-basedapplications

Results

Page 22: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

OracleSharding Strategy• Supersetofallsharding architectures(SQLandNoSQL)

– Pluggablereplication architecture• Supports allthereplicationmodels(master-slave,active-active,ring,etc.)

– Multiple sharding techniques• Consistenthash,range,list,composite

– Tunableconsistency• Withinandacrossshards.Plusuniquely,high-performancestrongconsistencyacrossshards

– Continuumofshared-disk andshared-nothing capabilities– Standards-based (SQLandJava9)

• Plusuniquecapabilitiesarounddatasovereigntyandmulti-cloud

OracleRestricted 22

Page 23: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

ProgramAgenda

ActiveDataGuard

Sharding

GloballyDistributedDatabase

PlannedDowntime

AutonomousDatabaseandCloud

1

2

3

4

5

Confidential– OracleInternal/Restricted/HighlyRestricted 23

Page 24: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.| Confidential– OracleInternal/Restricted/HighlyRestricted

OracleSharded DatabaseisaGloballyDistributedDatabaseWhywouldyouwanttodothis?

• Datasovereignty– dataforcountrymustbestored&replicated in-country

• Querydataacrossall regions• DisasterRecovery– primaryandstandby(s)canbefarapart

• Lowlatencyforreads– readfromnearestreplica;withloadbalancingandfailover

• Lowlatencyforwrites ifdataispartitionedproperly.E.g.,locateEuropeandatainEuropeandatacenter

• Single logicaldatabase – application&DBAsseeonedatabase

OneLogical Database

Page 25: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

DataSovereignty(Pattern1)andMulti-Cloud

25

UserDefinedSharding

ShardedDatabaseUser-defined shards onhybrid cloud

• DataSovereigntyrequiresdatatobekept inthecountry

• 18cUser-Defined Sharding (LISTorRANGE) letsyoucreateashardforeachcountry– AddCOUNTRYcolumntoeachtable

• Applications withinthecountrycandirectlyaccess shardwithoutasharding key

• Queryacrossallcountriesbyconnecting toCoordinatorandissuemulti-shard queries

• OtherUseCases– Multi-Cloud(shardacross2ormoreclouds)– HybridCloudandCloudBursting

• Some shards onpremises; other shards inthecloud

OracleConfidential– Restricted

Coordinator(Global)

US EU

JAPAN

Page 26: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

DataSovereigntywithGlobalSingleInstance(Pattern2)

26

Most datacentralizedwithsome datashardedbycountry

ShardedDatabase• Havingglobalsingle instance isbeneficial

– Strongdataconsistencybyeliminatingduplication• Centralizebulkofyourdata

– Keeponlysubset(e.g.,CUSTOMER,andotherPersonallyIdentifiableInformationPII)inthecountriesoforigin

– Canqueryandrunreportsacrossalldata(centralizedandcountry-specific)

• WithOracleSharding– Createalltablesinacentralshardcatalog– Placecertaindataacrosscountry-specificshards– Seeallthedatausingmulti-shardquerycoordinator– Applicationalwaysconnecttocoordinatordatabase

Page 27: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

HowDoesOracleSharding ComparewithAlternatives?

Confidential– OracleInternal/Restricted/HighlyRestricted

Page 28: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

RealandFakeNews• GoogleCloudSpannerasclaimed:

–Onlyenterprise-grade,globally-distributed,andstronglyconsistentdatabaseserviceforthecloud

–Combinesbenefitsofrelational databasestructurewithnon-relationalhorizontalscale

–Querydatausingfamiliar,industry-standardANSI2011SQL–High-performancetransactions andstrongconsistencyacrossrows,regions,andcontinentswithanindustry-leading99.999% availabilitySLA..andenterprisegradesecurity

• RealNews:strongconsistency,relationalmodel,ANSISQL,andtransactionsarecool!

OracleRestricted 28

Page 29: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

UPDATE savings_accountsSETbalance =balance- 500WHEREcust_id =12345ANDaccount=3209;

UPDATE checking_accountsSETbalance =balance+500WHEREcust_id =12345ANDaccount=3208;

INSERT INTOjournal(tran_code, cust_id,account,balance,change_amount)SELECT (13,cust_id,account,balance,-500)FROM savings_accounts WHERE cust_id = 12345ANDaccount=3209;

INSERT INTOjournal(tran_code, cust_id,account,balance,change_amount)SELECT (12,cust_id,account,balance,500)FROMchecking_accounts WHERE cust_id =12345ANDaccount=3208;

COMMIT WORK;

DoesThisSQLRunonSpanner?

Decrement Savings Acct(Savings tableconstraint:amount>$100)

Increment Checking Acct

Journal thetransfer operations(tran_cod 13– transfer fromtran_code 12– transfer to)

End transaction

Transfer$500fromSavingsAccounttoCheckingAccount

29OracleConfidential

Page 30: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

static voidwriteWithTransact ion(Dat aba seC lient dbClient) {dbClient.readWriteTransaction().run(

new TransactionCallable <Void>() {@Overridepublic Void run(TransactionContext transaction) throws Exception {//Transfer $500 fromSAVINGS toCHECKING.We do the transfer in atransaction to//ensure that the transfer is atomic.Struct row=transaction.readRow( "SAVINGS_ ACCOUNTS ", Key.of(12345, 3209),

Arrays.asList("SavingsRow"));long savingsBalance =row.getLong(2);//Transaction will only becommitted if sufficient funds (>$100) constraint ismet//at the timeofcommit.Otherwise itwill beaborted and thecallable will be rerun//by theclient library.if (savingsBalance >=600) {longcheckingBalance =transaction

.readRow("CHECKING_ACCOUNTS ", Key.of(12345, 3208),Arrays.asList("Checking sRow"))

.getLong(2);long transfer =500;checkingBalance +=transfer;savingsBalance -=transfer;transaction.buffer(Mutation.newUpdate Bu ilder( "CHE CKING_ ACCOUNTS ")

.set("cust_id")

.to(12345)

.set("account")

.to(3208)

.set("CheckingsRow")

.to(checkingBalance)

.build());transaction.buffer(Mutation.newUpdate Bu ilder( "SAVINGS_ACCOUNTS")

.set("cust_id")

.to(12345)

.set("account")

.to(3209)

.set("SavingsRow")

.to(savingsBalance)

.build());

// Lognewbalances, cannot readyour own writes//mutations: checkingBalance, savingsBalance//must fit inmemory!transaction.buffer(Mutation.newInsertBui lde r("JOURN AL")

.set("tran_code")

.to(13)

.set("cust_id")

.to(12345)

.set("account")

.to(3209)

.set("balance")

.to(savingsBalance)

.set("change_amount")

.to(transfer)

.build());transaction.buffer(Mutation.newInsertBui lde r("JOURN AL")

.set("tran_code")

.to(12)

.set("cust_id")

.to(12345)

.set("account")

.to(3208)

.set("balance")

.to(checkingBalance)

.set("change_amount")

.to(transfer)

.build());}return null;

}});

}// writeWithTransaction

/* transfer $500 fromsavings tochecking *//*all tables aresharded bycust_id *//*savings tableconstraint: amount >$100*/UPDATE savings_accountsSETbalance =balance - 500 WHERE cust_id =12345 ANDaccount=3209;

UPDATE checking_accountsSETbalance =balance +500WHERE cust_id =12345 ANDaccount=3208;

/* log newbalances (readyourown writes) *//* tran_code =13– transfer from*/INSERT INTOjournal (tran_code, cust_id, account, balance, change_amount)SELECT (13, cust_id, account, balance, -500)FROM savings_accounts WHERE cust_id =12345 ANDaccount=3209;

/* tran_code =12– transfer to*/INSERT INTOjournal (tran_code, cust_id, account, balance, change_amount)SELECT (12, cust_id, account, balance, 500)FROM checking_accounts WHERE cust_id =12345ANDaccount =3208;

COMMIT WORK;

OracleSQLvsSpannerProgram(ApplicationTransparent!NOT)

30OracleConfidential

Page 31: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

OracleSharded DatabaseisaGloballyDistributedDatabase• Single logicaldatabasewithreplicasacrossdatacentersandregions• Applications seesone logicaldatabase

– Connect toasingle ‘service’ andberouted totherightreplica– Routing takesintoaccount: network latency, replica response time, anddataheld byeach replica– Handles failover; i.e.,routetoagood replica iforiginal is unavailable– Handle add anddropof replicas (thatmaycontain disjoint data)

• Managethereplicasasasingledatabase– Administrators donotneedtomaintain theirspreadsheet of nodes, whoreplicates towhom, and perform admin

operations Ntimesforeach replica– Globalmetadataand viewof thephysical databases (replicas), datatheycontain, replication topology, etc.– Automatic configuration of replication– Automatic propagation ofmanagement operations (DDLs, passwd files, …)toallreplicas– Rebalance dataandsynchronize stateasnodes areadded/dropped

• OracleSharding doesallthis,whilesupportdatasovereigntyandmulti-cloud

OracleRestricted 31

Page 32: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

ProgramAgenda

ActiveDataGuard

Sharding

GloballyDistributedDatabase

PlannedDowntime

AutonomousDatabaseandCloud

1

2

3

4

5

Confidential– OracleInternal/Restricted/HighlyRestricted 32

Page 33: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

PlannedMaintenanceisKeytoUptime• Unplanned downtimeisrarewithwell-runsystems

– Hardware/softwarefailuresareautomatically handled byMAA

• Keytobestuptimeisreducingplanned downtime– Makeapplication schema changesonline– Applypatchesandupgradesonlineorrolling

• Focusonautomationtomakethemsimple• UseApplicationContinuitytohidedowntimefromapplications

33

Page 34: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

Patching Improvements• Zero-DowntimeOracleGridInfrastructurePatching

– PatchOracleGridInfrastructurewithout interruptingdatabase operations.– Patchesareapplied out-of-place andina rollingfashionwithonenodebeingpatchedatatimewhilethedatabase instance(s)onthatnoderemain upandrunning.

– SupportedforOracleRACandRACOneNodeclusterswithtwoormorenodes.

• OJVMisOracleRACrollingpatchingenabledwithOracleRAC18c(18.4)– Non-Javaservices areavailableatalltimes.– Javaservices areavailableall thetime, exceptfora~10secondsbrownout.

• Noerrorsarereportedduringthebrownout.

Page 35: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

Applicationsseenoerrorsduringmaintenance• Whenweshutdownaninstancefor

maintenance, itisbest ifallappsrelease theirconnections• However, manyapplications donot explicitly disconnect,

preventing usfrom shutting down instance

• 18cDatabaseandDriversreclaimconnectionswhereapplications donotnoticepriortomaintenance• Example:EndofWebrequests, Transaction

boundaries,Connection tests,Connectionreturnedtopool,andCustomrules

• Applications thatdonotrelease theirconnections arefailedover

35

Application ormid-tier testsconnections

Databasemarkssessionstoreclaim

AutomaticallyreclaimConnections

Clients

Page 36: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

FailoverApplicationsthatdonotReleasetheirConnections

36

DatabaseRequest

Errors/Timeoutshidden

TransparentApplicationContinuity

Clients • Sessions thatdonotrelease theirconnectionsmustbekilled.TransparentApplication Continuitythenrestoressession onanother instance

• Keyinnovations– Tracksessionstateasitchanges.Thisisverifiedduringreplay

– Automaticallyenablesanddisablescaptureofreplaystate• Disables capture aftercommits sincewedonotreplaycommitted transactions (orstatements withside-effects)

• Automatically re-enables

– Automaticallytrimstheclient’sreplayhistory– HandlesSYSDATE,sequences, …

Page 37: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

ActiveDataGuardRollingDatabaseUpgrades(DBMS_ROLLING)AutomatedTransientLogicalStandby(Oracle12c)

DatabaseA DatabaseBDBMS_ROLLING.INIT_PLANDBMS_ROLLING.BUILD_PLANDBMS_ROLLING.START_PLAN

Synchronize

SynchronizeSTBY

Dotheupgrade(DBUA)

SWITCHOVERDBMS_ROLLING.SWITCHOVERSTBY

SynchronizeDBMS_ROLLING.FINISH_PLANSTBY

Page 38: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

EnhancementstoDBMS_ROLLING(18cand19c)• DBMS_ROLLING requiressupportinglogicalreplicationofeachdatatype

– Allthecommondatatypesarefullysupportedduringrollingupgrade– 18cand19caddedmore:BigSCN,LongIdentifiers,SDO_GEORASTER, TOPOLOGY,REF,top-level varrays attributes, SDO_RDF_TRIPLE_S,…

• Newapproachtohandlethefewremainingunsupportedtypes– Keyobservation: unsupported datatypesareokifnotupdated duringupgrade– In19c,weblockupdatestothese unsupported types(andplsql)duringarollingupgrade• Feasible ascustomers candisable certainreportsandbatchjobsduringupgrades

– Allowsdatabases containingunsupported typestouseDBMS_ROLLING

Confidential– OracleInternal/Restricted/HighlyRestricted

Page 39: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

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

EnterpriseEdition(EE)ActiveDataGuardandGoldenGate

ZeroDowntimeUpgrade(ZDU)

EnterpriseEdition(EE)FullyAutomatedWorkflow EnterpriseEdition(EE)Robust,Fast&SpaceEfficient

Clone

SwitchOver

Upgrade

SwitchBack

• FastcloningwithSnapshots fordatabaseshostedonACFS

• FullDatabasecopyalsosupported

Robust

• Resume-ableafterfailures

• Revertibleforfastrollback/fallback.

Fast&SpaceEfficient

SyncUp

• Automaticsetup/teardownandconfigurationofActiveDataGuard(TransientLogicalStandby)orGoldenGate

• Worksfrom11.2.0.4

Page 40: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

OnlineOperations

• DBMS_REDEFINITION allowsyoutoreorganizeandredefinetables online– Add/drop/rename columns,switchphysicalstoragestructures,reorgtable,transformdata…online

• DBMS_REDEFINITION enhanced in12.2foreventhe largest,busiest databases:– Fullrestartability (resumeatpointoffailure)– Entireredefinitionprocessrunswithout acquiringExclusiveDDLlock– Maintaindependent MVsduringredefinition– V$online_redef forprogressmonitoring– Support forBinaryXMLstoragechanges,BFILE,invisiblecolumns

• 18c,19caddedsupportfortableswithbitmapjoinindexes, hybridpartitioning, rowarchival,andbothspatial indexandVPDpolicies

OnlineRedefinitionImprovements

Source Table

Update Tracking

Transform

CopyTable

TransformUpdates

Result Table

Continuous Queries & Updates

Store Updates

Page 41: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

OnlineOperationsDon’tbringdownOracletomakeschemachanges!

11.2 &Prior Createindex online, rebuildindexonline,rebuildindexpartitiononlineAddColumn,AddConstraintenablenovalidate

12.1 OnlinemovepartitionDropindex onlineSet unused columnonline,altercolumnvisible/invisible,alterindexunusableonline,alter indexvisible/invisiblealterindexparallel/noparallel

12.2 Altertablemoveonlinefornon-partitionedtablesAltertablefromnon-partitionedtopartitionedonlineAltertablesplitpartitiononlineCreatetableforexchange (usableforonlinepartitionexchange)Move/merge/splitpartitionmaintenanceoperationscannowdodatafiltering

18.1 Altertablemodify partitioned tabletoadifferent partitioningmethod (e.g.,hash torange)Altertablemergepartition/subpartition online

Page 42: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

OnlineOperations

• 18cand19cenhancedtoreduceimpactofonlineDDLsonrunningsystems• Improvedconcurrencybetweenmultiplepartitionmaintenanceoperations• 18cand19cdoesintelligent, fine-grainedcursorinvalidation(avoidingblanketcursorinvalidation)– Fine-grained invalidation(treatDMLandSELECTcursorsdifferently)– Rolling invalidation (existing, possiblysub-optimal cursorscanstill beused)– CREATE/DROP/ALTER INDEX,TRUNCATE TABLE, PartitionMaintenance Operations,DDLsonunusable andinvisible indexes, …

Evenbetterwith19c

Page 43: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

ProgramAgenda

ActiveDataGuard

Sharding

GloballyDistributedDatabase

PlannedDowntime

AutonomousDatabaseandCloud

1

2

3

4

5

43

Page 44: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

MaximumAvailabilityArchitecture(MAA)OracleAutonomousDatabase– Ingredient1

AutonomousDatabase

• MAAadoptedasastandardbymanycompanies largeandsmall– All4TopUSbanks(JPMC,BoA,Citibank,WellsFargo)adoptedMAA

• MAAisOracle’sbest recommended architecture– Ifyouwanttoastandardizedarchitecture– pickwhatthatOraclerecommendsandthatothercrediblecustomershaveadopted

– ThesecustomersstandardizedonMAAonlyafterduediligence

• Leveragethecollective know-how,experienceofOracleandothercompaniessuchasJPMC,BoA,PayPal,…

Page 45: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

OracleAutonomousDatabase– Ingredient2Exadata• Exadata standardizesthehardwareandconfiguration• Standardizationacrosscustomersbringsgreaterreliability.Fixesfoundbyothercustomersdirectlyhelpyoubemorestable

• Exadata istheonlyplatformthatcandothis– Samereliability asNewYorkStockExchangeandtopbanks

worldwide• Exadata alsoprovidesuniqueavailabilityadvantages

– In-memoryqueryonActiveDataGuard,RACSharding,Nologging loadswithActiveDataGuard,ActiveDataGuardmulti-instanceparallelredoapply…

• Evenifthereiszero uniquecapability,Exadata wouldstillbringgreaterreliabilitybecauseofstandardization

AutonomousDatabase

Page 46: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency

Copyright©2018, Oracleand/oritsaffiliates.Allrightsreserved.|

OracleAutonomousDatabase– Ingredient3CloudManagementwithMachine Learning• MAA+Exadata providesastandardarchitecture,software,andhardwareconfiguration

• TheAutonomousDatabasesoftwarethenmakesthisentireinfrastructureself-managingandself-healing

• All3ingredients:MAA,Exadata,andAutonomousDatabasesoftwarecombinetotouniquelyprovide99.995%NXAvailability

AutonomousDatabase

Page 47: High Availability and Sharding with Oracle ... - Oracle Cloud · •SGCC is adopting Microservice architecture for the growing business •Microservice architecture provides resiliency