




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
CHANGEDATACAPTURE(CDC)
INORACLE
VenkiKrishnababuSeniorOracleDBANordstromIT
11/28AGENDACDCINTRODUCTIONCDCCONCEPTSCDCCASESTUDYCDCPROCESSFLOWCDCPUBLISHER/SUBSCRIBERSETUPCDCBESTPRACTICEDEMOQ&A22/28INTRODUCTIONCDCisanoracletoolwhichcanhelptomanagedatachangesandcapturetheminconsistentmannerwithpredefinedAPIs.CDCisnotadevelopmentsolutiontoperformanyvalidationsortransformationorprovideanyapplicationspecificchecksetc.CDCdoesn’trequireanychangestotheexistingdatamodel.CDCmostcommonlyusedtocapturetransactionalchangesfromanOLTPsystemandpublishthechangestooneormoresubscriptionsystems.33/28CONVENTIONALMETHODTOCAPTUREDATACHANGESCAPTURINGDATACHANGETableDifferencingHeavyresourceintensiveSQLsIntermediatechangevaluescannotbecapturedMultiplechangesononetransactioncannotbecapturedChangeValueBasedonTimestampPotentiallyexpensivequeriesagainstSourceTables.IntermediatechangevaluescannotbecapturedMultiplechangesononetransactioncannotbecapturedPossibilityofmissingachangedrecordduringextractSourcesystemhavetobedesigngivingconsiderationtothisapproach.CustomBuiltTriggersCustomDevelopmentwork.Costassociatedwithextensivedevelopmentandtesting.Costproportionaltothecomplexityoftheproject.Ifnotdesignedproperlycanpotentiallycauseperformanceissuestosourcesystem.44/28WHATCDCCANOFFERCDCofferscostsavingsbysimplifyingtheextractionofchangedatafromdatabaseasitspartofOracle9idatabaseandlaterversions.CDCCaptureschangedataresultantofDMLoperationsincludingthebeforeandafterupdatevaluesofanupdateoperation.Datachangesarecapturedautomaticallytochangetable.VeryfriendlysimpletouseAPIstopublishandsubscribetothechanges.Canbescriptedwithverylittleeffort.AsynchronousCDCcapturesdatawithverylittleperformanceimpact.Bestofbothworlds.Automaticpurgeofconsumedorobsoletechangedatacapturedinchangetable.CDCensuresthateverysubscriberseesallchanges.Efficienttrackingofmultiplesubscribersandprovidesasharedaccesstothechangeddata.55/28WHATCDCCANNOTDO?CDCpurelyworkedbasedonloggedoperations,soanynonloggedDMLoperationsarenotcaptured.CDCdoesn’tsupportdirectloadinsert.CDCcannotbeimplementedontablewithTDE(TransparentDataEncryption)enabled.Asynchronousmodecapturewontworkwithoutsupplementallogging.Althoughdirectselectispossibleonchangetablebuttheextractionofthechangeddataisvalid/supportedonlyviasubscriberviews.66/28Changes#1Changes#2Table#1Table#2PUBLISHERSUBSCRIBERSubscription#1Subscription#2CDCCONCEPTSPUBLISHER/SUBSRIBERMODEL77/28SYNCHRONOUSCDCBasedonTriggersSupportedinOracle9iandlaterversionsTriggersonsourcedatabasecapturesthechangeimmediately.Captureddataismadepartofthesourcesystemtransaction.AvailablewithStandardandenterpriseedition.Addsoverheadtothesourcesystemduringthecapturetime.Built-intriggersareautomaticallycreatedbyinvokingtheCDCAPIs.88/28ASYNCHRONOUSCDC(HOTLOGMODE)ChangesarecapturedfromredologfilesaftertheDMLtransactioniscompleted.Changeddataisnotpartofthesourcetransaction.Minimallatencyinvolved.MinimalPerformanceoverheadtosourcesystem.Logwriterrecordsthecommittedtransactionstoonlineredologs.LocalOracleStreamprocessreadstheredologfilesandcapturesthechangestochangetable.99/28ASYNCHRONOUSCDC(AUTOLOGMODE)Changesarecapturedfromsetofredologfilesmanagedbyredotransportservice.(PartofDataGuardFramework).AutologOnlineMode:Changesarecapturedfromredologfiles.AutologArchiveMode:Changesarecapturedfromarchivelogfiles.Changeddataisnotpartofthesourcetransaction.Minimallatencyinvolved.MinimalPerformanceoverheadtosourcesystem.IfthechangesareextractedtoachangetableinastagingthedataistransferredviaLANusingOracleNet.SourceandstagingdatabaseshouldrunsameOSandOracleVersion.1010/28CDCTERMINOLOGYCHANGESOURCELogicalrepresentationofSourceDatabase.CHANGESETLogicalgroupingofChangedata.Thisgroupingenablestoprovidetransactionconsistentimagesofmultiplechangetablesinthesameset.Changetableswithinachangesetcanbejoined.CHANGETABLEChangedataresultingofDMLoperationarestoredinthetable.Thistableactsacontainer/stagingareatostagechangeddata.SubscriptionviewsarebuiltbasedonChangetable.PUBLISHERPersonwhocapturesandpublisheschangeddata.DBAcreatesandmaintainsschemaobjectsmakeuppartofCDC.Usuallyonepublisherpersourcesystem.1111/28CDCTERMINOLOGY(Contd..)SUBSCRIBERApplicationsandindividualswhoconsumethechangeddata.Multipleapplicationscansubscribetothesamesetofchanges.STAGINGDATABASEDatabasetowhichthecapturedchangedataisapplied.SourceDatabasecanbestagingdatabase.SUBCRIBERVIEWViewthatspecifiesthechangedatafromaspecificpublicationinasubscription.SUBSCRIPTIONWINDOWRangeofrowsinapublicationthatthesubscribercanviewthroughsubscriberviews.1212/28CDCCaseStudyCaptureSupplierinformationchangesfromInventorysystem.NearrealtimeSupplierinformationupdate.Averagefewhundredsupplierinformationchangesperday.Verylittlecodingeffort.Scopeistojustcapturethechangesonsuppliermastertable.CDCImplementationMode:SynchronousPublisher:1ChangeSet:1Subscriber:11313/28CDCCaseStudy(Contd..)PL/SQLtoextract/transformchangedataPublish/subscribeparadigmParalleltransformationofdataStorefinalprocessedchangeddatainstagingtable.OrextractthechangeinatransformedformthechangetableOLTPDBChangeTableBasedOnTriggerOracle9iFinal/DWTablesPL/SQLTransform1414/28CDCCASESTUDY(Contd..)POSSIBLEFUTUREENHANCEMENTSUpgradetoOracle10gRelease2.TurnonSupplementalloggingonSupplierMaster.PerformAsynchronousmodedatachangecaptureusing(HotlogMode).Disablesynchronousmodedatachangecapture.ImplementAsynchronousCDCtoestablishCIM(CommonInformationModel)forproduct.1515/28CDCSETUPOUTLINEPUBLISHERSETUP:
Identifythesourcetables.Setupapublisher.Createchangetables.Optionallysetupdedicatedpublisherandsubscriberaccounts.1616/28CDCSETUPOUTLINE(CONTD.)SUBSCRIBERONETIMESETUP:Setupasubscriber.Subscribetothesourcetables.Activatethesubscription.CYCLICSUBSCRIPTIONPROCESS:SetuptheCDCwindowandextendthewindow.Consumethechangeddatausingsubscriberviews.Purgetheconsumeddatawindow.Repeatthestepsincycle.1717/28CDCPROCESSFLOW(OVERVIEW)1818/28SUBSCRIPTIONWINDOWMOVEMENT1919/28PUBLISHERSETUP--Step1:CreateChangeSetforcdc_demopublishbegindbms_cdc_publish.create_change_set(change_set_name=>'DEMO_DAILY',description=>'ChangeSetforemp_demotable',change_source_name=>'SYNC_SOURCE');end;/--Step2:CreateChangeTableforcdc_demopublishbegindbms_cdc_publish.create_change_table(owner=>'cdc_pub',change_table_name=>'emp_demo_changes',change_set_name=>'DEMO_DAILY',source_schema=>'HR',source_table=>'EMP_DEMO',column_type_list=>'EMPLOYEE_IDNUMBER,FIRST_NAMEVARCHAR2(35),LAST_NAMEVARCHAR2(35),SALARYNUMBER(8,2)',capture_values=>'BOTH',RS_ID=>'Y',ROW_ID=>'Y',USER_ID=>'Y',TIMESTAMP=>'N',OBJECT_ID=>'N',SOURCE_COLMAP=>'Y',TARGET_COLMAP=>'Y',OPTIONS_STRING=>'TABLESPACECDC_DATApctfree5pctused95');end;/grantselectoncdc_pub.emp_demo_changestocdc_sub;2020/28SUBSCRIBERONETIMESETUP--Step1:CreateSubscriptionbegindbms_cdc_subscribe.create_subscription(change_set_name=>'DEMO_DAILY',description=>'ChangedataforWH',subscription_name=>'EMP_DEMO_SUB');end;/--Step2:Subscribetorequiredcolumnsofsourcetablebegindbms_cdc_subscribe.subscribe(subscription_name=>'EMP_DEMO_SUB',source_schema=>'HR',source_table=>'EMP_DEMO',column_list=>'EMPLOYEE_ID,FIRST_NAME,LAST_NAME,SALARY',subscriber_view=>'v_emp_demo_changes');end;/--Step3:ActivateSubscriptionbegindbms_cdc_subscribe.activate_subscription(subscription_name=>'EMP_DEMO_SUB');end;/--Step4:ShowCDCSubscriberViewDefinition.(Optional)descv_emp_demo_changes2121/28SETUPCYCLICSUBSCRITPION--Step1Getthechange(extendthewindow).begindbms_cdc_subscribe.extend_window(subscription_name=>'EMP_DEMO_SUB');end;/--Step2ReadfromtheCDCview(capturethechange)selectemployee_id,first_name,last_name,salaryfromv_emp_demo_changes;--Step3Purgethewindowofconsumeddatabegindbms_cdc_subscribe.purge_window(subscription_name=>'EMP_DEMO_SUB');end;/2222/28SUBSCRIBERVIEWSAMPLEDEFINITIONCREATEORREPLACEFORCEVIEW"CDC_SUB"."V_EMP_DEMO_CHANGES"("OPERATION$","CSCN$","COMMIT_TIMESTAMP$","ROW_ID$","RSID$","SOURCE_COLMAP$","TARGET_COLMAP$","USERNAME$","EMPLOYEE_ID","FIRST_NAME","LAST_NAME","SALARY")ASSELECTOPERATION$,CSCN$,COMMIT_TIMESTAMP$,ROW_ID$,RSID$,SOURCE_COLMAP$,TARGET_COLMAP$,USERNAME$,"EMPLOYEE_ID","FIRST_NAME","LAST_NAME","SALARY"FROM"CDC_PUB"."EMP_DEMO_CHANGES"WHERECSCN$>=538180ANDCSCN$<=538179WITHREADONLY2323/28CDCSOMEBESTPRACTICECaptureoverheadisproportionaltoamountofdatawecapture,socaptureonlyrequire/relevantcolumnswhilecreatingchangetable.CreatededicatedpublisheraccounttoadministerCDCpublications.Splitpublicationstotwosubsetstoprovidesecuredsubsettoonesetofsubscribersandanothersubsettoanothersetofsubscribers.Ifoldvaluesarenotrequireensuretocaptureonlynewvalues.(parameterCAPTURE_VALUES=>’NEW’).Useforceloggingoptiontocaptureeventhechangesoutofdirectloadinsertorinsertswithnologging.Usethisforceloggingwithcautionasitmayintroduceperformanceoverhead.Tominimizeperformanceimpactoptionallyyoucanmovethesourcetabletoaseparatetablespaceandturnonforceloggingattablespacelevelinsteadofdatabaselevel.UseDBMS_CDC_PUBLISH.PURGE…proceduretopurgeobsoletedatafromchangetable.GettheauditinformationaspartoftheCDCcapture.Captureonlyselective/relevantcontrolcolumnsonthechangetable.Useoptions_stringclausetospecifystorageclauseandparameters.Donotspecifyany
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 創(chuàng)作靈感合同范例范例
- 碳內(nèi)部審計(jì)問題研究
- 養(yǎng)殖設(shè)備出售轉(zhuǎn)讓合同范例
- 會展物流服務(wù)合同范例
- 個人授課勞務(wù)合同范例
- 寫預(yù)售合同范例
- 借款附加協(xié)議合同范例
- 冷庫安裝商超合同范例
- 中介霸王合同范例
- 利潤借款合同范例
- 2025年湖南鐵道職業(yè)技術(shù)學(xué)院單招職業(yè)技能測試題庫1套
- 江蘇省中小學(xué)生金鑰匙科技競賽(高中組)考試題及答案
- 中國建筑史PPT(東南大學(xué))完整全套教學(xué)課件
- 籃球比賽記錄表(CBA專用)
- 人防門吊環(huán)后補(bǔ)方案
- 好書推薦-沈石溪《黑天鵝紫水晶》
- 《建筑識圖》匯總題庫(學(xué)生用)
- 印刷制品QC工程圖
- 單軌吊軌道的吊掛形式及安裝標(biāo)準(zhǔn)
- 王羲之蘭亭序書法大字字帖
- GB_T 12519-2021 分析儀器通用技術(shù)條件(高清-現(xiàn)行)
評論
0/150
提交評論