Вы находитесь на странице: 1из 32

OracleGoldenGateonLinux:BidirectionalReplicationfromOracle11gR2toOracle11gR2

Overview

Purpose

ThisOracleByExample(OBE)tutorialcoversinstalling,configuring,andmanagingOracleGoldenGateversion11.2.1.0.2onapairofLinuxOracle
11gR2databases.

TimetoComplete

Approximately3hours

Introduction

OracleGoldenGateprovidesveryfastreplicationofheterogeneousdatabasesbyreadingtransactionlogsandwritingthechangestooneormore
targetdatabases.Therearefiveprocessesinvolvedinatypicalenvironment:

Manager:
Startsandstopstheotherprocessesonboththesourceandtargethosts.NotrequiredonceExtractorReplicatisrunning.
InitialLoad:
Optional.Usedtopopulatethetargettablesonetime.ItcanreadeitherfromthesourcetablesdirectlyorfromASCIIfiles.ThisOBEwillnot
useanInitialLoad.
Extract:
Runsonthesourcetocapturetransactiondatatotrailfiles.TherearetwoversionsofExtract:Classic(thisOBE)andIntegrated.
DataPump:
Optional,buthighlyrecommended.SendstrailfilesfromthesourcetothetargetoveranIPnetwork.TechnicallyitisasecondaryExtract.
Replicat:
Deliversdatatothetargetdatabase.NormallytheReplicatrunsonthetarget.

Scenario

TherearetwoLinuxhostsrunningOracle11gR2:host01(red)andhost02(green).Host01hasauser/schemaogguser1withapasswordof
pswd1u,andanadministratorwithauser/schemaoggadm1withapasswordofpswd1a.

Host02hasauser/schemaogguser2withapasswordofpswd2u,andanadministratorwithauser/schemaoggadm2withapasswordofpswd2a.
Therearetablesonhost01(TCUSTMERandTCUSTORD)thatneedtobereplicatedtohost02.Payattentiontothecolorofthescreenbannerstoknow
whichcommandsaregoingtowhichhost.AlsonotewhetheryouareenteringGGSCIcommands,SQLcommands,orOScommands(theprompt
willguideyou).

Oncetheunidirectionalreplicationisworking,thereisanoptionaldesiretogobidirectional.ThatrequiresanadditionalinstanceoftheOracle
GoldenGatesoftware(asecondinstalldirectory).

Insummary,theenvironmentis:

HostName Color OS SID User Password Port InstallDirectory


HostName Color OS SID User Password Port InstallDirectory
ogguser1 pswd1u
host01 Red Linux64bit orcl01 15001 /u01/app/oracle/ogg01
oggadm1 pswd1a

host02 Green Linux64bit orcl02 ogguser2 pswd2u 15002 /u01/app/oracle/ogg02


oggadm2 pswd2a

HardwareandSoftwareRequirements

Thefollowingisalistofhardwareandsoftwarerequirements:

Hardware

TwoLinuxhosts:onesourceandonetarget.TheexampleusesOracleEnterpriseLinuxOEL5.7,64bit.AdifferentversionoftheOracle
GoldenGatesoftwarewillrunonWindows,or32bitLinuxaswell.Itispossibletohavethesourceandtargetbeonthesamehost,butthatis
conceptuallyhardertovisualizewhatishappening.Ifyoudohaveonlyonehost,itmaybehelpfultochangethe/etc/hostsfiletomake
aliasesforhost01.example.comandhost02.example.com.

Software

OracleGoldenGateonOracle,Linux64(OracleSoftwareDeliveryCloud),version11.2.1.0.2,partnumberV3433901.Thisisthepart
numberfor64bitLinux.
Oracle11gR2Databaseinstalledonbothhosts.

Prerequisites

Beforestartingthistutorial,youshould:

HaverootaccesstotheLinuxsoftware(writeaccessto/etc)
Havewebaccesstodownloadthesoftwareanddocumentation.
CreateadatabaseinstancewithSID=orcl01onhost01,andadatabaseinstancewithSID=orcl02onhost02.
Modifytnsnames.oraonbothhostssothattheycantalktoeachotherbySID.

Bearinmindthattherearetwohosts:host01andhost02andthateachhosthasthreeenvironmentprompts:OS,GGSCI,andSQL.Thatmakessix
differentplacesinwhichyoucouldbetyping!Trytobeextracarefulaboutwhichcommandyouenterinwhichlocation.Thewrongcommandinthe
wrongcontextisthemostcommonerror.

TypographicConventions

Textcolorandfontinthedirectionsandinthescreensshouldbeinterpretedasfollows:

Some_Command
Youtypethisasacommandoravalue.Example:
Enter./ggscitostartthecommandlineinterpreter.
Some_Prompt
Thesystemrespondswiththisasapromptorreply.Example:
Afterthewelcomesplashbanner,youcanentercommandsattheGGSCI(host01)1>prompt.
Some_Button
Clickthisonscreenbutton.Example:
Afterselectingtheversionyouwant,clickContinuetostartthedownload.
Some_Variable
Avariablethatyousubstitutewitharealvalue.Example:
Enteryouruserid/passwordattheprompt.
Some_Filename
Afilename,path,orfolder/directory.Example:
Editthehostsfileinthe/etcdirectory.
Some_Code
Akeywordorcodeelement.Example:
ChangetheparameterHandleCollisionstoNoHandleCollisionsaftertheinitialload.

Alsobecarefulaboutletter"oh"versusnumber"zero."TheSIDisorcl01(leadingohandtrailingzeroone).

FileandProcessNamingConventions

Fileandprocessnamingconventionscanbewhateverworksforyouoryourcompany.HerearethesampleconventionsusedinthisOBE:
pxxxxhh.ext
where:

p=process=
e(xtract),p(ump),r(eplicat),i(nitial),d(efgen),s(tartup).
xxxx=project=
Allfilesrelatedtoacommonprojectxxxx,forexamplehr,sales,engr.
hh=hosttohost=
aa,ab,ba,bb,asindicatedbysourceandtargethostnameswherea=host01,andb=host02.Lateronyouwillseethatyoucannotuse
numbersaspartofsomefilenames,sobetternottogothereatall.
ext=extension=
prm=parameter(storedindirprm/),dsc=discard,rpt=report(storedindirrpt/),def=definition(storedindirdef/),oby=obey(storedin
installationdirectory),sql=SQL(storedindirsql/).

1.InstallingtheSoftw are

Theinstallationofthesoftwareissimplyfetchingthezipfilesfromthewebandunzippingthem.ToinstalltheOracleGoldenGatesoftware,perform
Theinstallationofthesoftwareissimplyfetchingthezipfilesfromthewebandunzippingthem.ToinstalltheOracleGoldenGatesoftware,perform
thefollowingsteps:

1.1AccessingOracleGoldenGateDocumentation
1. Accessthedocumentationlibrary.

Usingawebbrowser,gotohttp://www.oracle.com/technetwork/middleware/goldengate/documentation/index.html.Youhavethe
optiontoeitherreadthedocumentsonline,ortodownloadthelibrarytoyourlocalworkstationaseitherPDForHTMLformat.

ClickViewLibrary.

ClickOracleInstallationandSetupGuide.ReadtheInstallationGuideforOracle.

YouhavesuccessfullyaccessedOracleGoldenGatedocumentationasaprerequisiteforinstallingthesoftware.

1.2InstallingOracleGoldenGateonLinux
1. CopythesoftwarefromOracleSoftwareDeliveryCloud.

Usingawebbrowser,gotohttps://edelivery.oracle.comandclickSignIn.OntheTermsandConditionspage,selectYesforboth
agreements,andclickContinue.

OntheMediaPackSearchpage,selectProductPack=OracleFusionMiddleware,andPlatform=Linuxx8664.
ClickGo.

SelectOracleGoldenGateonOraclev11.2.1MediaPackforLinuxx8664.

ClickContinue.

MakesureyouarelookingatpartnumberV3433901for"OracleGoldenGateV11.2.1.0.3forOracle11gonLinuxx8664."

ClickDownload.

2. Unpackthesoftwareinitsdirectoryonhost01(red).

CreatetheinstallationdirectorytoreceivetheOracleGoldenGatesoftware.

Host01Linux

[oggadm1@host01/]$cd/u01/app/oracle
[oggadm1@host01oracle]$mkdirogg01
[oggadm1@host01ogg01]$cdogg01/
[oggadm1@host01ogg01]$

Copythedownloadedzipfromwhereveryoudownloadedittoogg01/.Unzipitanduntar(extract)it.

Host01Linux
[oggadm1@host01ogg01]$cp/stage/V3433901.zip.
[oggadm1@host01ogg01]$unzipV3433901.zip

Archive:V3433901.zip
inflating:fbo_ggs_Linux_x64_ora11g_64bit.tar
inflating:Oracle_GoldenGate_11.2.1.0.3_README.doc
inflating:OracleGoldenGate_11.2.1.0.3_README.txt
inflating:OGG_WinUnix_Rel_Notes_11.2.1.0.3.pdf
[oggadm1@host01ogg01]$tarxvpffbo_ggs_Linux_x64_ora11g_64bit.tar
UserExitExamples/
UserExitExamples/ExitDemo_more_recs/
UserExitExamples/ExitDemo_more_recs/Makefile_more_recs.HPUX

...manylinesomittedforclarity...

ulg.sql
usrdecs.h
zlib.txt
[oggadm1@host01ogg01]$

Bemindfulofthetrailingdotinthecopycommand.

3. StarttheGoldenGateSoftwareCommandInterface(GGSCI).Createthedefaultemptysubdirectories.

Host01Linux

[oggadm1@host01ogg01]$./ggsci

OracleGoldenGateCommandInterpreterforOracle
Version11.2.1.0.314400833OGGCORE_11.2.1.0.3_PLATFORMS_120823.1258_FBO
Linux,x64,64bit(optimized),Oracle11gonAug23201220:20:21

Copyright(C)1995,2012,Oracleand/oritsaffiliates.Allrightsreserved.

GGSCI(host01)1>CreateSubdirs

Creatingsubdirectoriesundercurrentdirectory/u01/app/oracle/ogg01

Parameterfiles/u01/app/oracle/ogg01/dirprm:alreadyexists
Reportfiles/u01/app/oracle/ogg01/dirrpt:created
Checkpointfiles/u01/app/oracle/ogg01/dirchk:created
Processstatusfiles/u01/app/oracle/ogg01/dirpcs:created
SQLscriptfiles/u01/app/oracle/ogg01/dirsql:created
Databasedefinitionsfiles/u01/app/oracle/ogg01/dirdef:created
Extractdatafiles/u01/app/oracle/ogg01/dirdat:created
Temporaryfiles/u01/app/oracle/ogg01/dirtmp:created
Stdoutfiles/u01/app/oracle/ogg01/dirout:created

GGSCI(host01)2>Exit
[oggadm1@host01ogg01]$

Ifadirectoryalreadyexists,theinstallationleavesthecontentsofthatdirectoryalone.

4. Dothesamestepsfortheotherhost.Unpackthesoftwareinitsdirectoryonhost02(green).

CreatetheinstallationdirectorytoreceivetheOracleGoldenGatesoftware.

Host02Linux

[oggadm2@host02/]$cd/u01/app/oracle
[oggadm2@host02oracle]$mkdirogg02
[oggadm2@host02ogg02]$cdogg02/
[oggadm2@host02ogg02]$

Copythedownloadedzipfromwhereveryoudownloadedittoogg02/.Unzipitanduntar(extract)it.

Host02Linux

[oggadm2@host02ogg02]$cp/stage/V3433901.zip.
[oggadm2@host02ogg02]$unzipV3433901.zip
Archive:V3433901.zip
inflating:fbo_ggs_Linux_x64_ora11g_64bit.tar
inflating:Oracle_GoldenGate_11.2.1.0.3_README.doc
inflating:OracleGoldenGate_11.2.1.0.3_README.txt
inflating:OGG_WinUnix_Rel_Notes_11.2.1.0.3.pdf
[oggadm2@host02ogg02]$tarxvpffbo_ggs_Linux_x64_ora11g_64bit.tar
UserExitExamples/
UserExitExamples/ExitDemo_more_recs/
UserExitExamples/ExitDemo_more_recs/Makefile_more_recs.HPUX

...manylinesomittedforclarity...

ulg.sql
usrdecs.h
zlib.txt
zlib.txt
[oggadm2@host02ogg02]$

5. StarttheGoldenGateSoftwareCommandInterface(GGSCI).Createthedefaultemptysubdirectories.

Host02Linux

[oggadm2@host02ogg02]$./ggsci

OracleGoldenGateCommandInterpreterforOracle
Version11.2.1.0.314400833OGGCORE_11.2.1.0.3_PLATFORMS_120823.1258_FBO
Linux,x64,64bit(optimized),Oracle11gonAug23201220:20:21

Copyright(C)1995,2012,Oracleand/oritsaffiliates.Allrightsreserved.

GGSCI(host02)1>CreateSubdirs

Creatingsubdirectoriesundercurrentdirectory/u01/app/oracle/ogg02

Parameterfiles/u01/app/oracle/ogg02/dirprm:alreadyexists
Reportfiles/u01/app/oracle/ogg02/dirrpt:created
Checkpointfiles/u01/app/oracle/ogg02/dirchk:created
Processstatusfiles/u01/app/oracle/ogg02/dirpcs:created
SQLscriptfiles/u01/app/oracle/ogg02/dirsql:created
Databasedefinitionsfiles/u01/app/oracle/ogg02/dirdef:created
Extractdatafiles/u01/app/oracle/ogg02/dirdat:created
Temporaryfiles/u01/app/oracle/ogg02/dirtmp:created
Stdoutfiles/u01/app/oracle/ogg02/dirout:created

GGSCI(host02)2>Exit
[oggadm2@host02ogg02]$

Ifadirectoryalreadyexists,theinstallationleavesthecontentsofthatdirectoryalone.

YouhavesuccessfullyinstalledOracleGoldenGateonLinuxhostshost01andhost02.

2.ConfiguringtheEnvironment

TheconfigurationoftheenvironmentisdonebyeditingASCIIfilesandrunningOSutilities.Toconfiguretheenvironment,performthefollowing
steps:

2.1ConfiguringtheOracle11gR2Databases
1. ThissectionmustbedoneinSQL*Plusassysdba.

Onhost01,verifythatLOG_MODEissettoARCHIVELOG.

Host01Linux

[oggadm1@host01ogg01]sqlplus/assysdba
SQL*Plus:Release11.2.0.3.0ProductiononMonSep1717:19:012012
Copyright(c)1982,2011,Oracle.Allrightsreserved.

Connectedto:
OracleDatabase11gEnterpriseEditionRelease11.2.0.3.064bitProduction
WiththePartitioning,OLAP,DataMiningandRealApplicationTestingoptions

SQL>SELECTlog_modeFROMv$database

LOG_MODE

ARCHIVELOG

SQL>

TheresultshouldbeARCHIVELOG.Ifitis,thenskiptothenextstep.IftheresultisNOARCHIVELOG,thendothefollowing:

Host01Linux

LOG_MODE

NOARCHIVELOG

SQL>shutdownimmediate
Databaseclosed.
Databasedismounted.
ORACLEinstanceshutdown.
SQL>startupmount
ORACLEinstancestarted.

TotalSystemGlobalArea3340451840bytes
FixedSize2232960bytes
VariableSize1811942784bytes
DatabaseBuffers1509949440bytes
DatabaseBuffers1509949440bytes
RedoBuffers16326656bytes
Databasemounted.
SQL>ALTERDATABASEARCHIVELOG
Databasealtered.

SQL>ALTERDATABASEOPEN
Databasealtered.

SQL>SELECTlog_modeFROMv$database

LOG_MODE

ARCHIVELOG

SQL>

2. Verifythatsupplementalloggingandforcedloggingaresetproperly.

Host01Linux

SQL>SELECTforce_logging,supplemental_log_data_minFROMv$database

FORSUPPLEME

YESYES

SQL>

TheresultsshouldbothbeYES.Ifitis,thenskiptothenextstep.IfeitherresultisNO,thendothefollowing:

Host01Linux

FORSUPPLEME

NONO

SQL>ALTERDATABASEADDSUPPLEMENTALLOGDATA
Databasealtered.

SQL>ALTERDATABASEFORCELOGGING
Databasealtered.

SQL>ALTERSYSTEMSWITCHLOGFILE
Systemaltered.

SQL>SELECTforce_logging,supplemental_log_data_minFROMv$database

FORSUPPLEME

YESYES

SQL>

Thereisnoharmindoingthecommandstwice.

3. Createtheadministratoranduser/schemaownersonhost01.

Inreallife,theuser/schemaownerwouldprobablyhavemoreprivileges,andtheadministratorwouldhavelessprivileges.The
DBMS_GOLDENGATE_AUTHpackageisnotneededforthisOBE,butiscommonlyusedinmoreadvancedconfigurations,soitisagood
ideatoseeithere.Oddly,theDBAroleisnotsufficientforadvancedscenariosyoumustalsoruntheDBMS_GOLDENGATE_AUTH
package.WhenkeyingintheDBMS_GOLDENGATE_AUTHcommand,theentirestringafterEXECiswithoutspacesorlinebreaks.

Host01Linux

SQL>CREATEUSERogguser1IDENTIFIEDBYpswd1u
Usercreated.

SQL>CREATEUSERoggadm1IDENTIFIEDBYpswd1a
Usercreated.

SQL>GRANTCONNECT,RESOURCE,UNLIMITEDTABLESPACETOogguser1
Grantsucceeded.

SQL>GRANTdbaTOoggadm1
Grantsucceeded.

SQL>EXECDBMS_GOLDENGATE_AUTH.GRANT_ADMIN_PRIVILEGE(grantee=>'OGGADM1',privile
ge_type=>'capture',grant_select_privileges=>true,do_grants=>TRUE)
PL/SQLproceduresuccessfullycompleted.

SQL>exit
[oggadm1@host01ogg01]$
4. Verifythatbothdatabasescantalktoeachother.

Testinterdatabasecommunicationwithtnsping.

Host01Linux

[oggadm1@host01ogg01]$tnspingorcl01
TNSPingUtilityforLinux:Version11.2.0.3.0Productionon17SEP201218:52
Copyright(c)1997,2011,Oracle.Allrightsreserved.
Usedparameterfiles:

UsedTNSNAMESadaptertoresolvethealias
Attemptingtocontact(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(
HOST=host01.example.com)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl01.
example.com)))
OK(0msec)

[oggadm1@host01ogg01]$tnspingorcl02
TNSPingUtilityforLinux:Version11.2.0.3.0Productionon17SEP201218:52
Copyright(c)1997,2011,Oracle.Allrightsreserved.
Usedparameterfiles:

UsedTNSNAMESadaptertoresolvethealias
Attemptingtocontact(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(
HOST=host02.example.com)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl02.
example.com)))
OK(10msec)

[oggadm1@host01ogg01]$

TheresultsshouldbeOK.Ifitis,thenskiptothenextstep.IfitisnotOK,thendothefollowingtoexaminetnsnames.ora.

Host01Linux

[oggadm1@host01ogg01]$more$ORACLE_HOME/network/admin/tnsnames.ora
#tnsnames.oraNetworkConfigurationFile:/u01/app/oracle/product/11.2.0/dbhome_
1/network/admin/tnsnames.ora
#GeneratedbyOracleconfigurationtools.

ORCL02=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)(HOST=host02.example.com)(PORT=1521))
)
(CONNECT_DATA=
(SERVICE_NAME=orcl02.example.com)
)
)

ORCL01=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)(HOST=host01.example.com)(PORT=1521))
)
(CONNECT_DATA=
(SERVICE_NAME=orcl01.example.com)
)
)

[oggadm1@host01ogg01]$

Youshouldhaveorcl01andorcl02definedintnsnames.ora.

5. Everythingyoudidforthedatabaseorcl01onhost01needstobedonefororcl02onhost02.

Onhost02,verifythatLOG_MODEissettoARCHIVELOG.

Host02Linux

[oggadm2@host02ogg02]sqlplus/assysdba
SQL*Plus:Release11.2.0.3.0ProductiononMonSep1717:19:012012
Copyright(c)1982,2011,Oracle.Allrightsreserved.

Connectedto:
OracleDatabase11gEnterpriseEditionRelease11.2.0.3.064bitProduction
WiththePartitioning,OLAP,DataMiningandRealApplicationTestingoptions

SQL>SELECTlog_modeFROMv$database

LOG_MODE

ARCHIVELOG

SQL>

TheresultshouldbeARCHIVELOG.Ifitis,thenskiptothenextstep.IftheresultisNOARCHIVELOG,thendothefollowing:
Host02Linux

LOG_MODE

NOARCHIVELOG

SQL>shutdownimmediate
Databaseclosed.
Databasedismounted.
ORACLEinstanceshutdown.
SQL>startupmount
ORACLEinstancestarted.

TotalSystemGlobalArea3340451840bytes
FixedSize2232960bytes
VariableSize1811942784bytes
DatabaseBuffers1509949440bytes
RedoBuffers16326656bytes
Databasemounted.
SQL>ALTERDATABASEARCHIVELOG
Databasealtered.

SQL>ALTERDATABASEOPEN
Databasealtered.

SQL>SELECTlog_modeFROMv$database

LOG_MODE

ARCHIVELOG

SQL>

6. Verifythatsupplementalloggingandforcedloggingaresetproperly.

Host02Linux

SQL>SELECTforce_logging,supplemental_log_data_minFROMv$database

FORSUPPLEME

YESYES

SQL>

TheresultsshouldbothbeYES.Ifitis,thenskiptothenextstep.IfeitherresultisNO,thendothefollowing:

Host02Linux

FORSUPPLEME

NONO

SQL>ALTERDATABASEADDSUPPLEMENTALLOGDATA
Databasealtered.

SQL>ALTERDATABASEFORCELOGGING
Databasealtered.

SQL>ALTERSYSTEMSWITCHLOGFILE
Systemaltered.

SQL>SELECTforce_logging,supplemental_log_data_minFROMv$database

FORSUPPLEME

YESYES

SQL>

Thereisnoharmindoingthecommandstwice.

7. Createtheadministratoranduser/schemaownersonhost02.

Host02Linux

SQL>CREATEUSERogguser2IDENTIFIEDBYpswd2u
Usercreated.

SQL>CREATEUSERoggadm2IDENTIFIEDBYpswd2a
Usercreated.

SQL>GRANTCONNECT,RESOURCE,UNLIMITEDTABLESPACETOogguser2
SQL>GRANTCONNECT,RESOURCE,UNLIMITEDTABLESPACETOogguser2
Grantsucceeded.

SQL>GRANTdbaTOoggadm2

Grantsucceeded.

SQL>EXECDBMS_GOLDENGATE_AUTH.GRANT_ADMIN_PRIVILEGE(grantee=>'OGGADM2',privile
ge_type=>'capture',grant_select_privileges=>true,do_grants=>TRUE)
PL/SQLproceduresuccessfullycompleted.

SQL>exit
[oggadm2@host02ogg02]$

8. Verifythatbothdatabasescantalktoeachother.

Testinterdatabasecommunicationwithtnsping.

Host02Linux

[oggadm2@host02ogg02]$tnspingorcl01
TNSPingUtilityforLinux:Version11.2.0.3.0Productionon17SEP201218:52
Copyright(c)1997,2011,Oracle.Allrightsreserved.
Usedparameterfiles:

UsedTNSNAMESadaptertoresolvethealias
Attemptingtocontact(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(
HOST=host01.example.com)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl01.
example.com)))
OK(0msec)

[oggadm2@host02ogg02]$tnspingorcl02
TNSPingUtilityforLinux:Version11.2.0.3.0Productionon17SEP201218:52
Copyright(c)1997,2011,Oracle.Allrightsreserved.
Usedparameterfiles:

UsedTNSNAMESadaptertoresolvethealias
Attemptingtocontact(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(
HOST=host02.example.com)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl02.
example.com)))
OK(10msec)

[oggadm2@host02ogg02]$

TheresultsshouldbeOK.Ifitis,thenskiptothenextstep.IfitisnotOK,thendothefollowingtoexaminetnsnames.ora.

Host02Linux

[oggadm2@host02ogg02]$more$ORACLE_HOME/network/admin/tnsnames.ora
#tnsnames.oraNetworkConfigurationFile:/u01/app/oracle/product/11.2.0/dbhome_
1/network/admin/tnsnames.ora
#GeneratedbyOracleconfigurationtools.

ORCL02=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)(HOST=host02.example.com)(PORT=1521))
)
(CONNECT_DATA=
(SERVICE_NAME=orcl02.example.com)
)
)

ORCL01=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)(HOST=host01.example.com)(PORT=1521))
)
(CONNECT_DATA=
(SERVICE_NAME=orcl01.example.com)
)
)

[oggadm2@host02ogg02]$

Youshouldhaveorcl01andorcl02definedintnsnames.ora.

Thedatabasesonhost01andhost02areconfiguredtosupportOracleGoldengate.Usersoneachdatabaseareprovisioned:one(ormore)
userandanadministratorforeachhost.

2.2CreatingStartupFilesandManagers
1. CreatetheGLOBALSfileonhost01(red)intheOracleGoldenGateinstallationdirectoryusingyourtexteditorofchoice.

Itispossibletocreateand/oredittheGLOBALSfilefrominsideGGSCIbyprependingthenamewith"./".Forexample:
GGSCI>EditParam./GLOBALS
exceptthatforittotakeeffect,youhavetoleaveandreenterGGSCI,soyoumightaswelldotheeditingoutsideGGSCIbeforeyoustart
exceptthatforittotakeeffect,youhavetoleaveandreenterGGSCI,soyoumightaswelldotheeditingoutsideGGSCIbeforeyoustart
GGSCIthefirsttime.

TheGLOBALSfilenamemustbeallUPPERCASE,anditcontainsonlyoneline(pluscomments)definingthecheckpointtable
schemaandname.Youcanuseanyschemaandanyname.Youcanuseviorgeditoranytexteditor.

Host01Linux

[oggadm1@host01ogg01]viGLOBALS
CreatedbyJoeAdmin10/11/2012onhost01
CheckpointTableoggadm1.oggchkpt

[oggadm1@host01ogg01]

CheckpointtablesareonlyusedbytheReplicat,sothiswillnotbeuseduntilthebidirectionalsection.Havingitpresentandunused
doesnothurtanything.

2. CreatetheGLOBALSfileonhost02(green)intheOracleGoldenGateinstallationdirectory.

Host02Linux

[oggadm2@host02ogg02]$viGLOBALS
CreatedbyJoeAdmin10/11/2012onhost02
CheckpointTableoggadm2.oggchkpt

[oggadm2@host02ogg02]$

AnychangetotheGLOBALSfilerequiresarestartofGGSCI.

3. Createtheoptionalstartup.oby(Obey)fileonhost01(red)intheOracleGoldenGateinstallationdirectory.

TheseareGGSCIcommandsthataredonealmosteverytimeyoustartGGSCI,andtheydonotpersistbetweensessions,soyouwill
findyourselfenteringthemmany,manytimes,andthereforeitisconvenienttocreateastartupobeyfile.

Ifyouhaveseveraldifferentdatabasesorschemasthatyoulogintoonaregularbasis,youmaywanttomakestartup01.oby,
startup02.oby,startup03.oby,andsoon.Thiswillberevisitedlaterinthenamingconventionsofprocessfiles.

Host01Linux

[oggadm1@host01ogg01]vistartup.oby
CreatedbyJoeAdmin10/11/2012onhost01
DBLoginUserIDoggadm1@orcl01,Passwordpswd1a
StartMgr
InfoMgr
InfoCheckpointTable
SetEditorgedit

[oggadm1@host01ogg01]

DBLogin:
ConnectstotheDBusingtheuserid@SID/passwordspecified.The@SIDisoptionalifthereisnoambiguity.
StartMgr:
IftheManagerisalreadystarted,thereisnoharmintryingtostartitagain.Thisispersistentbetweensessions.
InfoMgr:
ReportsiftheManagerstartedsuccessfully,andifso,theportnumberbeingused.
InfoCheckpointTable:
Reportsifacheckpointtable(usedbyReplicat)wasfound.
SetEditor:
Thedefaultisvi.YoucantemporarilychangethattoaGUIeditorsuchasgedit.

4. Createtheoptionalstartup.oby(Obey)fileonhost02(green)intheOracleGoldenGateinstallationdirectory.

Host02Linux

[oggadm2@host02ogg02]$vistartup.oby
CreatedbyJoeAdmin10/11/2012onhost02
DBLoginUserIDoggadm2@orcl02,Passwordpswd2a
StartMgr
InfoMgr
InfoCheckpointTable
SetEditorgedit

[oggadm2@host02ogg02]$

5. CreatetheManagerparameter(mgr.prm)fileonhost01indirprm/.

StartGGSCI.Editthefilewithnoextension.Addthetwolines(pluscomments).

Host01Linux

[oggadm1@host01ogg01]./ggsci
OracleGoldenGateCommandInterpreterforOracle
Version11.2.1.0.314400833OGGCORE_11.2.1.0.3_PLATFORMS_120823.1258_FBO
Linux,x64,64bit(optimized),Oracle11gonAug23201220:20:21
Copyright(C)1995,2012,Oracleand/oritsaffiliates.Allrightsreserved.

GGSCI(host01)1>EditParammgr
CreatedbyJoeAdmin10/11/2012onhost01
Port15001
PurgeOldExtracts./dirdat/*,UseCheckpoints

GGSCI(host01)2>Infomgr
ManagerisDOWN!

GGSCI(host01)3>

Note:Ifyoudoitcorrectly,GGSCIautomaticallyaddsthe.prmextensionandstoresthefileinthedirprm/directory.Ifyouwronglyadd
theextensionyourself,GGSCIconvertsthefilenametoUPPERCASEandstoresitintheinstallationdirectorywhichrendersthefile
practicallyunusable.

6. CreatetheManagerparameter(mgr.prm)fileonhost02indirprm/.

Host02Linux

[oggadm2@host02ogg02]$./ggsci
OracleGoldenGateCommandInterpreterforOracle
Version11.2.1.0.314400833OGGCORE_11.2.1.0.3_PLATFORMS_120823.1258_FBO
Linux,x64,64bit(optimized),Oracle11gonAug23201220:20:21
Copyright(C)1995,2012,Oracleand/oritsaffiliates.Allrightsreserved.

GGSCI(host02)1>EditParammgr
CreatedbyJoeAdmin10/11/2012onhost02
Port15002
PurgeOldExtracts./dirdat/*,UseCheckpoints

GGSCI(host02)2>Infomgr
ManagerisDOWN!

GGSCI(host02)3>

Noticethattheportnumberisdifferentfromhost01tohost02.IftheOracleGoldenGateinstancesareondifferenthosts,youdon'thave
tomaketheportsdifferent,aslongasthecomb inationofIPaddressplusportisunique.Nevertheless,itisagoodpracticetomake
theportsunique.

7. StarttheManageronhost01usingtheObeyfiles.Alternatively,youcouldtypeeachofthelineseverytimeyoustartGGSCI.

Host01Linux

GGSCI(host01)3>Obeystartup.oby

GGSCI(host01)4>CreatedbyJoeAdmin10/11/2012onhost01

GGSCI(host01)5>DBLoginUserIDoggadm1@orcl01,Passwordpswd1a
Successfullyloggedintodatabase.

GGSCI(host01)6>StartMgr
Managerstarted.

GGSCI(host01)7>InfoMgr
Managerisrunning(IPporthost01.example.com.15001).

GGSCI(host01)8>InfoCheckpointTable

Nocheckpointtablespecified,usingGLOBALSspecification(oggadm1.oggchkpt)...
Checkpointtableoggadm1.oggchkptdoesnotexist.

GGSCI(host01)9>SetEditorgedit

GGSCI(host01)10>

Youwillcreatethecheckpointtableinthenextstep.

8. StarttheManageronhost02usingtheObeyfiles.

Host02Linux

GGSCI(host02)3>Obeystartup.oby

GGSCI(host02)4>CreatedbyJoeAdmin10/11/2012onhost02

GGSCI(host02)5>DBLoginUserIDoggadm2@orcl02,Passwordpswd2a
Successfullyloggedintodatabase.

GGSCI(host02)6>StartMgr
Managerstarted.
Managerstarted.

GGSCI(host02)7>InfoMgr
Managerisrunning(IPporthost02.example.com.15002).

GGSCI(host02)8>InfoCheckpointTable

Nocheckpointtablespecified,usingGLOBALSspecification(oggadm2.oggchkpt)...
Checkpointtableoggadm2.oggchkptdoesnotexist.

GGSCI(host02)9>SetEditorgedit

GGSCI(host02)10>

Youwillcreatethecheckpointtableinthenextstep.

Theglobalandstartupfilesareallcreated,andthebackgroundManagerprocessesarestarted.Youcanverifywhichprocessesarerunningat
anytimebyenteringthecommand:
GGSCI(host)>InfoAll

2.3CreatingTables
1. Createthecheckpointtableonhost01.(Thisisnotneededonthesource,sothisiswillnotbeusedforunidirectionalreplication,but
willbeusedforbidirectionalreplicationwhenhost01becomesthetarget.)

Host01Linux

GGSCI(host01)10>AddCheckpointTable

Nocheckpointtablespecified,usingGLOBALSspecification(oggadm1.oggchkpt).
Successfullycreatedcheckpointtableoggadm1.oggchkpt.

GGSCI(host01)11>Exit

[oggadm1@host01ogg01]

Onecheckpointtablewillsufficeforthewholeschema.

2. Createthecheckpointtableonhost02.

Host02Linux

GGSCI(host02)10>AddCheckpointTable

Nocheckpointtablespecified,usingGLOBALSspecification(oggadm2.oggchkpt).
Successfullycreatedcheckpointtableoggadm2.oggchkpt.

GGSCI(host02)11>Exit

[oggadm2@host02ogg02]$

3. Createemptysourcesampletablesonhost01inschemaogguser1.

Ifyoualreadyhavesampletables,youcanusethose.Ifnot,OracleGoldenGatesoftwarecomeswithascriptdemo_ora_create.sql
tocreatetwosmallsampletablestcustmerandtcustord.YoucanuseanySQLutilityyouliketorunthescript.Ifyouhaveno
preference,usesqlplus.

Host01Linux

[oggadm1@host01ogg01]sqlplusogguser1@orcl01/pswd1u@demo_ora_create.sql

SQL*Plus:Release11.2.0.3.0ProductiononTueSep1814:38:502012
Copyright(c)1982,2011,Oracle.Allrightsreserved.

Connectedto:
OracleDatabase11gEnterpriseEditionRelease11.2.0.3.064bitProduction
WiththePartitioning,OLAP,DataMiningandRealApplicationTestingoptions

DROPTABLEtcustmer
*
ERRORatline1:
ORA00942:tableorviewdoesnotexist

Tablecreated.

DROPTABLEtcustord
*
ERRORatline1:
ORA00942:tableorviewdoesnotexist

Tablecreated.

SQL>exit
[oggadm1@host01ogg01]
TheORA00942"errors"areokaytoignore.Ifyourunthescriptasecondtimeyouwon'tseethoseerrors.

Warning!Ifyourunthescriptasecondtime,itwilldropthetables!
4. Createemptytargetsampletablesonhost02inschemaogguser2.

Host02Linux

[oggadm2@host02ogg02]sqlplusogguser2@orcl02/pswd2u@demo_ora_create.sql

SQL*Plus:Release11.2.0.3.0ProductiononTueSep1814:44:062012
Copyright(c)1982,2011,Oracle.Allrightsreserved.

Connectedto:
OracleDatabase11gEnterpriseEditionRelease11.2.0.3.064bitProduction
WiththePartitioning,OLAP,DataMiningandRealApplicationTestingoptions

DROPTABLEtcustmer
*
ERRORatline1:
ORA00942:tableorviewdoesnotexist

Tablecreated.

DROPTABLEtcustord
*
ERRORatline1:
ORA00942:tableorviewdoesnotexist

Tablecreated.

SQL>exit
[oggadm2@host02ogg02]$

Oracle11gR2doessupportreplicatingDDLsuchasCREATETABLE,andthereforetheemptytablescouldbecreatedonthetargetin
otherwaysbeforeanyDMLreplicationbegins.

YoucancheckonthetablesavailableanytimeGGSCIisrunning(afteryouhaverunObeystartup.obytologintothedatabase)byentering
thecommands:

GGSCI(host)>ListTables*
GGSCI(host)>ListTablesogguser1.*

2.4AddingTransactionData
1. RestartGGSCIandrunAddTranDataforthewholeuserschema.

Host01Linux

[oggadm1@host01ogg01]./ggsci
OracleGoldenGateCommandInterpreterforOracle
...manylinesomittedforclarity...

GGSCI(host01)1>Obeystartup.oby

...manylinesomittedforclarity...butmakesureeverythingstarted.

GGSCI(host01)>ListTables*
OGGADM1.OGGCHKPT
OGGADM1.OGGCHKPT_LOX

Found2tablesmatchinglistcriteria.

GGSCI(host01)>ListTablesogguser1.*
OGGUSER1.TCUSTMER
OGGUSER1.TCUSTORD

Found2tablesmatchinglistcriteria.

GGSCI(host01)>AddTranDataogguser1.tcustmer

LoggingofsupplementalredodataenabledfortableOGGUSER1.TCUSTMER.

GGSCI(host01)>AddTranDataogguser1.tcust*

LoggingofsupplementalredologdataisalreadyenabledfortableOGGUSER1.TCUST
MER.

LoggingofsupplementalredodataenabledfortableOGGUSER1.TCUSTORD.

GGSCI(host01)>InfoTranDataogguser1.*

LoggingofsupplementalredologdataisenabledfortableOGGUSER1.TCUSTMER.
ColumnssupplementallyloggedfortableOGGUSER1.TCUSTMER:CUST_CODE.

LoggingofsupplementalredologdataisenabledfortableOGGUSER1.TCUSTORD.
ColumnssupplementallyloggedfortableOGGUSER1.TCUSTORD:CUST_CODE,ORDER_DATE,
ColumnssupplementallyloggedfortableOGGUSER1.TCUSTORD:CUST_CODE,ORDER_DATE,
PRODUCT_CODE,ORDER_ID.

GGSCI(host01)xx>

Notethatyoucanaddtransactiondataforanindividualtableorforwildcards.Thewildcardscanbeforawholeschema,butthereisa
betterwaytodowholeschemas.Thereisnoharminaddingtransactiondatatwice.

2. Doalmostthesamethingonhost02.(Thisisnotneededonthetarget,sothisiswillnotbeusedforunidirectionalreplication,butwill
beusedforbidirectionalreplicationwhenhost02becomesthesource.)

UseSchemaTranDatainsteadofjustTranData.

Host02Linux

[oggadm2@host02ogg02]./ggsci
OracleGoldenGateCommandInterpreterforOracle
...manylinesomittedforclarity...

GGSCI(host02)1>Obeystartup.oby

...manylinesomittedforclarity...butmakesureeverythingstarted.

GGSCI(host02)>ListTablesogguser2.*
OGGUSER2.TCUSTMER
OGGUSER2.TCUSTORD

Found2tablesmatchinglistcriteria.

GGSCI(host02)>AddSchemaTranDataogguser2
2012091815:18:34INFOOGG01788SCHEMATRANDATAhasbeenaddedonschemao
gguser2.

GGSCI(host02)>InfoSchemaTranDataogguser2
2012091815:21:06INFOOGG01785Schemalevelsupplementalloggingisenab
ledonschemaOGGUSER2.

GGSCI(host02)xx>

Theendresultforreplicationisthesame,butthereareseveraladministrativedifferenceswhenusingSchemaTranData:

NotablesshowupwhenyouqueryInfoTranDataogguser2.*,buttheyareinfactenabled.
Anynewtableaddedtotheschemabecomesautomaticallyenabledfortransactiondatalogging(withplainoldTranDatayou
wouldhavetomanuallyaddnewtableseachtimeforsupplementallogging.)
NotallotherOEMdatabasessupportSchemaTranData.

ThetransactiondatahasbeenenabledforallusertablesinvolvedwithOracleGoldenGate.

2.5CreatingColumnDefinitions(defgen)
1. CreatethecolumnmappingfromsourcetotargettablesusingtheOSutility.

Thisutilityisrequiredifthetableshaveadifferent(heterogeneous)structure,butisstillhighlyrecommendedevenifthetableshave
thesame(homogeneous)structure.Iftheydohavethesamestructure,youmaybeabletousetheAssumeTargetDefsparameter
insteadoftheSourceDefsparameter.Thisiscoveredlater.

PleasereviewtheFileandProcessNamingConventionsintheOverviewTopic.

Host01Linux

GGSCI(host01)>EditParamdsalesab
defgencolumndefinitionsforSales:tcust*fromhost01(a)tohost02(b)
CreatedbyJoeAdminon10/11/2012
DefsFiledirdef/dsalesab.def,Purge
UserIDoggadm1@orcl01,Passwordpswd1a
Tableogguser1.tcust*

GGSCI(host01)>Exit

[oggadm1@host01ogg01]./defgenparamfiledirprm/dsalesab.prm
***********************************************************************
OracleGoldenGateTableDefinitionGeneratorforOracle

...manylinesomittedforclarity...

Expandingwildcardogguser1.tcust*:

RetrievingdefinitionforOGGUSER1.TCUSTMER
RetrievingdefinitionforOGGUSER1.TCUSTORD

Definitionsgeneratedfor2tablesindirdef/dsalesab.def

[oggadm1@host01ogg01]

Youcancreatedefinitionsforasingletable,multipletables(usingwildcards),anentireschema,ormultipleschemasatatime.
Youcancreatedefinitionsforasingletable,multipletables(usingwildcards),anentireschema,ormultipleschemasatatime.
Having"excess"(thatis,unusedbyOracleGoldenGate)definitionsinthefileisnotaproblem.Youmaywanttoexaminethecontents
ofdirdef/dsalesab.defbeforesendingitovertohost02.

2. Copythefilesfromsourcehost01totargethost02.

Usewhatevermethodyouwishtocopythe.deffilestothetargetdirdefdirectory:cutnpaste,scp,ftp,andsoon.Theexample
willusesecureshellcopy(scp).Donotbreakthecommandlineafter/u01/app/oracle/og,thescpcommandisenteredallonone
line.

Host01Linux

[oggadm1@host01ogg01]scpdirdef/dsalesab.defoggadm2@host02:/u01/app/oracle/og
g02/dirdef
Theauthenticityofhost'host02(192.0.2.29)'can'tbeestablished.
RSAkeyfingerprintis8e:60:d0:a7:fc:55:6e:d9:81:bb:c9:90:19:f4:a8:11.
Areyousureyouwanttocontinueconnecting(yes/no)?yes
Warning:Permanentlyadded'host02,192.0.2.29'(RSA)tothelistofknownhosts.
oggadm2@host02'spassword:********
dsalesab.def100%18771.8KB/s00:00

[oggadm1@host01ogg01]

Ofcourseyoureplacetheasteriskswithyourpassword,forexamplepswd2a.

3. Makesurethefilesarrivedintactonhost02intheproperdirectory.

Host02Linux

[oggadm2@host02ogg02]$lsldirdef
total4
rwrr1oggadm2oinstall1877Sep1813:43dsalesab.def
[oggadm2@host02ogg02]$

Thecolumndefinitionsarecreatedandcopied.Ifthetablestructurechanges,youneedtodothisagain.

3.ConfiguringDataCaptureUsingExtract

Datacapture,alsoknownasExtract,isdoneonthesourceside.Aprimaryextractisrequiredasecondaryextract,knownasaDataPump,is
optionalbuthighlyrecommended.Toconfiguredatacapture,performthefollowingsteps:

3.1ConfiguringthePrimaryExtract
1. Onsourcehost01,createtheprimaryExtractparameterfile.

UsingthenamingconventionsdiscussedintheOverview,thepath/filename.extwillbedirprm/esalesaa.prm.Thepathand
extensionwillbeaddedautomatically.(Theprimaryextractcanwriteatrailfiledirectlytothetargethost,inwhichcasethesuffixwould
be"ab",butsinceitisgoingtoalocaldatapumpbeforeleavingthesourcehost,thesuffixis"aa".Allofthisisjustconvention,youcan
nametheprocessesanythingyouwant.)

Host01Linux

[oggadm1@host01ogg01]./ggsci
OracleGoldenGateCommandInterpreterforOracle
...manylinesomittedforclarity...

GGSCI(host01)1>Obeystartup.oby

...manylinesomittedforclarity...butmakesureeverythingstarted.

GGSCI(host01)>EditParamesalesaa
PrimaryExtractfromhost01tohost02
CreatedbyJoeAdminon10/11/2012
SETENV(ORACLE_SID="orcl01")
Extractesalesaa
ExtTrail./dirdat/aa
UserIDoggadm1@orcl01,Passwordpswd1a
TranLogOptionsExcludeUseroggadm1
Tableogguser1.tcust*

GGSCI(host01)>

Someoftheparameters:

:
Acomment.Usefulforselfdocumentingfiles,aswellasstoringparametersinlinethatmaybeusedlater.
SETENV:
YouhavetodefineSID(theDatabaseSystemIdentifier)somewhere:eitherinthe.profileorintheUserIDorhereinthe
SETENV.Onlyoneplaceisnecessary,thoughifyoudefineithereitoverrridesanypreviousdefinitionsinthe.profile.
ExtTrail:
Notreally"external"ifyouareusingadatapump.
aa:
aa:
Asequencenumberisappendededtothisalphabeticprefix.Forexample,thetrailfilesarenamedaa000000,aa000001,
aa000002,andsoon,rollingoverasthefilegrowsbeyondthespecifiedsize(default100MB).
TranLogOptions:
Usedlaterbybidirectionalreplicationtopreventloops.
Table:
YoucanhavemultipleTablestatements,eachwithonetablename(withoptionalwildcards)resolvingtozero,one,ormore
tables.Youcannotuseawildcardintheschemaname.

Itispossibletoencryptthepasswordsinthefile,butthatisbeyondthescopeofthisexercise.

YoucancheckyourworkbyenteringViewParamesalesaaanytime.

2. CreatetheExtractgroupandthelocalExtracttrailfile.

Host01Linux

GGSCI(host01)>AddExtractesalesaa,TranLog,BeginNow
EXTRACTadded.

GGSCI(host01)>AddExtTrail./dirdat/aa,Extractesalesaa,Megabytes5
EXTTRAILadded.

GGSCI(host01)>

TheMegabytes5isoptional.Thedefaultis100Megabytes.

TheprimaryExtracthasbeencreatedandconfigured,butnotstarted.LeaveGGSCIrunningforthenextstep.

3.2ConfiguringtheDataPump
1. CreatethesecondaryExtract(datapump)parameterfile.

UsingthenamingconventionsdiscussedintheOverview,thepath/filename.extwillbedirprm/psalesab.prm.Thepathand
extensionwillbeaddedautomatically.

Host01Linux

GGSCI(host01)>EditParampsalesab
Datapump(secondaryExtract)fromhost01tohost02
CreatedbyJoeAdminon10/11/2012
Extractpsalesab
RmtHosthost02,MgrPort15002,Compress
RmtTrail./dirdat/ab
Passthru
Tableogguser1.tcust*

GGSCI(host01)>

ThisTableschemaisthesource.

YoucancheckyourworkbyenteringViewParampsalesabanytime.

2. CreatethedatapumpgroupandtheremoteExtracttrailfile.

Host01Linux

GGSCI(host01)>AddExtractpsalesab,ExtTrailSource./dirdat/aa
EXTRACTadded.

GGSCI(host01)>AddRmtTrail./dirdat/ab,Extractpsalesab,Megabytes5
RMTTRAILadded.

GGSCI(host01)>

TheMegabytes5isoptional.Thedefaultis100Megabytes.

Thedatapumpreadsfromthelocaltrailfileaaandwritestotheremotetrailfileab.Theremotetrailfilethatwillbecreatedwillbe
nameddirdat/ab000000,thenwhenthatonefillsupthenextwillbedirdat/ab000001,thendirdat/ab000002,andsoon.Since
thetwosetsoftrailfilesareondifferenthosts(eventhoughtheyareindirectorieswiththesamenames),thefilescouldbenamedthe
samething(forexampleab).ThedifferentfilenameischosenjusttoillustratethattheparameterRmtTrailiscreatingadifferenttrail
file.

ThesecondaryExtracthasbeencreatedandconfigured,butnotstarted.LeaveGGSCIrunningforthenextstep.

3.3VerifytheExtractProcesses(Optional)
1. MakesuretheExtractprocesseswerecreatedandregisteredcorrectly.

Host01Linux

GGSCI(host01)>InfoAll
GGSCI(host01)>InfoAll

ProgramStatusGroupLagatChkptTimeSinceChkpt

MANAGERRUNNING
EXTRACTSTOPPEDESALESAA00:00:0000:03:24
EXTRACTSTOPPEDPSALESAB00:00:0000:01:22

GGSCI(host01)>

SincenothingotherthantheManagerisstartedyet,theExtractStatusshouldsaySTOPPED.

2. Makesurethetrailfileswerecreatedandregisteredcorrectly.

Host01Linux

GGSCI(host01)>InfoExtTrail*

ExtractTrail:./dirdat/aa
Extract:ESALESAA
Seqno:0
RBA:0
FileSize:5M

ExtractTrail:./dirdat/ab
Extract:PSALESAB
Seqno:0
RBA:0
FileSize:5M

GGSCI(host01)>

Sincenothinghasstartedyet,thesequencenumbers(Seqno)andrelativebyteaddresses(RBA)shouldsay0.

LeaveGGSCIrunningforthenextstep.

4.ConfiguringDataDeliveryUsingReplicat

Datadelivery,alsoknownasReplicat(the"e"isleftoffintentionally),isdoneatthetargetside.Toconfiguredatadelivery,performthefollowingsteps:

4.1ConfiguringtheReplicat
1. Ontargethost02,createtheReplicatparameterfile.

Host02Linux

[oggadm2@host02ogg02]$./ggsci
OracleGoldenGateCommandInterpreterforOracle
...manylinesomittedforclarity...

GGSCI(host02)1>Obeystartup.oby

...manylinesomittedforclarity...butmakesureeverythingstarted.

GGSCI(host02)>EditParamrsalesab
Deliveryfromhost01tohost02
CreatedbyJoeAdminon10/11/2012
Replicatrsalesab
UserIDoggadm2@orcl02,passwordpswd2a
AssumeTargetDefs
SourceDefsdirdef/dsalesab.def
DiscardFiledirrpt/rsalesab.dsc,Append
Mapogguser1.tcustmer,Targetogguser2.tcustmer
Mapogguser1.*,Targetogguser2.*

GGSCI(host02)>

TheMapstatementcanbesimple(asshownhere),orverycomplex,transformingcolumnsandfields.Forexample,youcould
combinethreesourcecolumnsfirst_name,middle_init,last_nameintoasingletargetcolumnfull_name.

2. CreatetheReplicatprocess.

Host02Linux

GGSCI(host02)>AddReplicatrsalesab,ExtTrail./dirdat/ab
REPLICATadded.

GGSCI(host02)>

YoucancheckyourworkbyenteringViewParamrsalesabanytime.

3. MakesuretheReplicatprocesswascreatedandregisteredcorrectly.
3. MakesuretheReplicatprocesswascreatedandregisteredcorrectly.

Host02Linux

GGSCI(host02)>InfoAll

ProgramStatusGroupLagatChkptTimeSinceChkpt

MANAGERRUNNING
REPLICATSTOPPEDRSALESAB00:00:0000:00:33

GGSCI(host02)>

SincenothingotherthantheManagerisstartedyet,theReplicatStatusshouldsaySTOPPED.

4.2StartingAllProcesses
1. StartallExtractprocessesonthesource.

Host01Linux

GGSCI(host01)>StartExtract*

SendingSTARTrequesttoMANAGER...
EXTRACTESALESAAstarting

SendingSTARTrequesttoMANAGER...
EXTRACTPSALESABstarting

GGSCI(host01)>

Alternatively,youcouldhaveentered,Start*,orStarte*andStartp*.

2. StartallReplicatprocessesonthetarget.

Host02Linux

GGSCI(host02)>StartReplicat*

SendingSTARTrequesttoMANAGER...
REPLICATRSALESABstarting

GGSCI(host02)>

Alternatively,youcouldhaveentered,Start*,orStartrsales*.

3. Displayinformationaboutallprocessesonthetarget.

Displaysummaryinformation.

Host02Linux

GGSCI(host02)>InfoAll

ProgramStatusGroupLagatChkptTimeSinceChkpt

MANAGERRUNNING
REPLICATRUNNINGRSALESAB00:00:0000:00:03

GGSCI(host02)>

Displaymoreinformation.

Host02Linux

GGSCI(host02)>Inforsalesab

REPLICATRSALESABLastStarted2012091919:13StatusRUNNING
CheckpointLag00:00:00(updated00:00:04ago)
LogReadCheckpointFile./dirdat/bc000001
FirstRecordRBA0

GGSCI(host02)>

Displaythemostdetailedinformation.

Host02Linux

GGSCI(host02)>Inforsalesab,Detail

REPLICATRSALESABLastStarted2012091919:13StatusRUNNING
CheckpointLag00:00:00(updated00:00:09ago)
CheckpointLag00:00:00(updated00:00:09ago)
LogReadCheckpointFile./dirdat/ab000000
FirstRecordRBA0

ExtractSourceBeginEnd

./dirdat/ab000000*Initialized*FirstRecord
./dirdat/ab000000*Initialized*FirstRecord

Currentdirectory/u01/app/oracle/ogg02

Reportfile/u01/app/oracle/ogg02/dirrpt/RSALESAB.rpt
Parameterfile/u01/app/oracle/ogg02/dirprm/rsalesab.prm
Checkpointfile/u01/app/oracle/ogg02/dirchk/RSALESAB.cpr
Checkpointtableoggadm2.oggchkpt
Processfile/u01/app/oracle/ogg02/dirpcs/RSALESAB.pcr
Stdoutfile/u01/app/oracle/ogg02/dirout/RSALESAB.out
Errorlog/u01/app/oracle/ogg02/ggserr.log

GGSCI(host02)>

Inallcases,theStatusshouldbeRUNNING,andthetimesincethelastupdateorcheckpointshouldbeunder10seconds.

4. Displayinformationaboutallprocessesonthesource.

Displaysummaryinformation.

Host01Linux

GGSCI(host01)>InfoAll

ProgramStatusGroupLagatChkptTimeSinceChkpt

MANAGERRUNNING
EXTRACTRUNNINGESALESAA00:00:0000:00:04
EXTRACTRUNNINGPSALESAB00:00:0000:00:05

GGSCI(host01)>

Displaydetailedinformation.

Host01Linux

GGSCI(host01)>InfoExtract*

EXTRACTESALESAALastStarted2012091919:12StatusRUNNING
CheckpointLag00:00:00(updated00:00:08ago)
LogReadCheckpointOracleRedoLogs
2012091919:21:49Seqno18,RBA29845504
SCN0.1372459(1372459)

EXTRACTPSALESABLastStarted2012091919:12StatusRUNNING
CheckpointLag00:00:00(updated00:00:01ago)
LogReadCheckpointFile./dirdat/ab000000
FirstRecordRBA0

GGSCI(host01)>Exit
[oggadm1@host01ogg01]

SimilartotheReplicat,theStatusshouldbeRUNNING,andthetimesincethelastupdateorcheckpointshouldbeunder10seconds.

EverythingshouldshowastatusofRUNNING.Thesourcetablesarestillempty.Nodatahasflowedyet,nothinghasreplicatedyet.

5.GeneratingData

TheOracleGoldenGatesoftwarecomeswithSQLscriptstogeneratesampledatatraffic.Thereisadifferenceinhowyoureplicateanexistingtable
(morecomplicated)versusstartingwithanewemptytable(simpler).Togeneratesampledataagainstanemptysetoftables,performthefollowing
steps:

5.1GeneratingINSERTs(InitialLoad)
1. RuntheSQLscripttoINSERTrows.

Onsourcehost01,attheOSprompt,runthedemo_ora_insert.sqlscriptinsqlplus.

Host01Linux

[oggadm1@host01ogg01]sqlplusogguser1@orcl01/pswd1u@demo_ora_insert.sql

SQL*Plus:Release11.2.0.3.0ProductiononWedSep1919:27:032012
Copyright(c)1982,2011,Oracle.Allrightsreserved.

Connectedto:
OracleDatabase11gEnterpriseEditionRelease11.2.0.3.064bitProduction
WiththePartitioning,OLAP,DataMiningandRealApplicationTestingoptions
WiththePartitioning,OLAP,DataMiningandRealApplicationTestingoptions

1rowcreated.

1rowcreated.

1rowcreated.

1rowcreated.

Commitcomplete.

SQL>

Thereshouldnotbeanyerrors.LeaveSQL*Plusrunningforthenextstep.

2. Verifythattherowswereinsertedintothesourcetables.

Host01Linux

SQL>SELECT*FROMtcustmer

CUST_CODENAMECITYSTATE

WILLBGSOFTWARECO.SEATTLEWA
JANEROCKYFLYERINC.DENVERCO

SQL>SELECT*FROMtcustord

CUSTORDER_DATPRODUCT_ORDER_IDPRODUCT_PRICEPRODUCT_AMOUNTTRANSACTION_ID

WILL30SEP94CAR144175203100
JANE11NOV95PLANE2561333001100

SQL>exit
[oggadm1@host01ogg01]

3. VerifythatthesourceGGSCIExtractprocessesarestillrunning.

Onsourcehost01,enterthefollowingcommand:

Host01Linux

[oggadm1@host01ogg01]./ggsci
GGSCI(host01)1>InfoAll

ProgramStatusGroupLagatChkptTimeSinceChkpt

MANAGERRUNNING
EXTRACTRUNNINGESALESAA00:00:0000:00:00
EXTRACTRUNNINGPSALESAB00:00:0000:00:06

GGSCI(host01)2>Exit
[oggadm1@host01ogg01]

IftheStatussaysABENDED,thenchecktheprocessreports(coveredasalatertopic)toseewhattheerrorwas.

4. VerifythatthetargetGGSCIReplicatprocessesarestillrunning.

Ontargethost02,GGSCIshouldstillberunning.Enterthefollowingcommand:

Host02Linux

GGSCI(host02)>InfoAll

ProgramStatusGroupLagatChkptTimeSinceChkpt

MANAGERRUNNING
REPLICATRUNNINGRSALESAB00:00:0000:00:05

GGSCI(host02)>Exit
[oggadm2@host02ogg02]

IftheStatussaysABENDED,thenchecktheprocessreports(coveredasalatertopic)toseewhattheerrorwas.

5. Verifythatrowshavebeeninsertedintothetargettables.

Ontargethost02,attheOSprompt,runthefollowingSQLqueries:

Host02Linux

[oggadm2@host02ogg02]sqlplusogguser2@orcl02/pswd2u
SQL>SELECT*FROMtcustmer

CUST_CODENAMECITYSTATE
CUST_CODENAMECITYSTATE

WILLBGSOFTWARECO.SEATTLEWA
JANEROCKYFLYERINC.DENVERCO

SQL>SELECT*FROMtcustord

CUSTORDER_DATPRODUCT_ORDER_IDPRODUCT_PRICEPRODUCT_AMOUNTTRANSACTION_ID

WILL30SEP94CAR144175203100
JANE11NOV95PLANE2561333001100

SQL>exit
[oggadm2@host02ogg02]

Thesourceandtargetdatabasetcust*tablesshouldmatch.

Therearealternativewaysofdoingtheinitialloadonthetargetifthesourcealreadyhasrowsinit,butthisisthesimplestwaywhenbothtables
areinitiallyempty.

5.2GeneratingUPDATEs/DELETEs
1. RuntheSQLscripttoUPDATEandDELETErows.

Onsourcehost01,attheOSprompt,runthedemo_ora_misc.sqlscriptinsqlplus.

Host01Linux

[oggadm1@host01ogg01]sqlplusogguser1@orcl01/pswd1u@demo_ora_misc.sql

...manylinesomittedforclarity...

Commitcomplete.

3rowsdeleted.

Rollbackcomplete.

SQL>

Thereshouldnotbeanyerrors.

2. Verifythattherowswereupdatedanddeletedinthesourcetables.

Host01Linux

SQL>SELECT*FROMtcustmer

CUST_CODENAMECITYSTATE

WILLBGSOFTWARECO.SEATTLEWA
JANEROCKYFLYERINC.DENVERCO
DAVEDAVE'SPLANESINC.TALLAHASSEEFL
BILLBILL'SUSEDCARSDENVERCO
ANNANN'SBOATSNEWYORKNY

SQL>SELECT*FROMtcustord

CUSTORDER_DATPRODUCT_ORDER_IDPRODUCT_PRICEPRODUCT_AMOUNTTRANSACTION_ID

BILL31DEC95CAR765140003100
BILL01JAN96TRUCK3332500015100
WILL30SEP94CAR144165203100

SQL>exit
[oggadm1@host01ogg01]

Threerowsinsertedintotcustmer,threerowsinsertedintotcustord,fourrowsupdatedintcustord,tworowsdeletedfrom
tcustord.

3. VerifythatthesourceGGSCIExtractprocessesarestillrunning.

Onsourcehost01,enterthefollowingcommand:

Host01Linux

[oggadm1@host01ogg01]./ggsci
GGSCI(host01)1>InfoAll

ProgramStatusGroupLagatChkptTimeSinceChkpt

MANAGERRUNNING
EXTRACTRUNNINGESALESAB00:00:0000:00:09
EXTRACTRUNNINGPSALESAB00:00:0000:00:01

GGSCI(host01)2>
GGSCI(host01)2>

(Forsomethingastrivialasthis,youdonotneedtorunObeystartup.oby,thoughitcouldn'thurt.)IftheinitialINSERTsworked,the
oddsarethattheUPDATEsandDELETEswillworkaswell.

4. VerifythatthetargetGGSCIReplicatprocessesarestillrunning.

Ontargethost02,GGSCIshouldstillberunning.Enterthefollowingcommand:

Host02Linux

GGSCI(host02)>InfoAll

ProgramStatusGroupLagatChkptTimeSinceChkpt

MANAGERRUNNING
REPLICATRUNNINGRSALESAB00:00:0000:00:09

GGSCI(host02)>Exit
[oggadm2@host02ogg02]

TheStatusshouldstillbeRUNNING.

5. Verifythatrowshavebeenupdatedanddeletedinthetargettables.

Ontargethost02,runthefollowingSQLqueries:

Host02Linux

[oggadm2@host02ogg02]sqlplusogguser2@orcl02/pswd2u
SQL>SELECT*FROMtcustmer

CUST_CODENAMECITYSTATE

WILLBGSOFTWARECO.SEATTLEWA
JANEROCKYFLYERINC.DENVERCO
DAVEDAVE'SPLANESINC.TALLAHASSEEFL
BILLBILL'SUSEDCARSDENVERCO
ANNANN'SBOATSNEWYORKNY

SQL>SELECT*FROMtcustord

CUSTORDER_DATPRODUCT_ORDER_IDPRODUCT_PRICEPRODUCT_AMOUNTTRANSACTION_ID

WILL30SEP94CAR144165203100
BILL31DEC95CAR765140003100
BILL01JAN96TRUCK3332500015100

SQL>exit
[oggadm2@host02ogg02]

ThiscompletestheconfigurationandoperationofthebasicunidirectionalfunctionalityofOracleGoldenGate:Extract,DataPump,andReplicat.

6.ManagingtheOracleGoldenGateEnvironment

Therearereportsgeneratedduringandaftertheprocessesrun.Thesereportscontaininformation,warnings,anderrors(ifany)relatedtothatrunof
theprocess.Toviewthereports,performthefollowingsteps:

6.1ViewingReports
1. Viewtheprocessreportsonthesource.

ViewtheprocessreportfortheExtract.

Host01Linux

GGSCI(host01)2>SendExtractesalesaa,Report

SendingREPORTrequesttoEXTRACTESALESAA...
Requestprocessed.

GGSCI(host01)3>ViewReportesalesaa
***********************************************************************
OracleGoldenGateCaptureforOracle
Version11.2.1.0.314400833OGGCORE_11.2.1.0.3_PLATFORMS_120823.1258_FBO
Linux,x64,64bit(optimized),Oracle11gonAug23201220:32:12
Copyright(C)1995,2012,Oracleand/oritsaffiliates.Allrightsreserved.

Startingat2012091919:12:33
***********************************************************************

OperatingSystemVersion:Linux
Version#1SMPWedJul2721:02:33EDT2011,Release2.6.32200.13.1.el5uek
Node:host01.example.com
Node:host01.example.com
Machine:x86_64
softlimithardlimit
AddressSpaceSize:unlimitedunlimited

HeapSize:unlimitedunlimited
FileSize:unlimitedunlimited
CPUTime:unlimitedunlimited

Processid:18569

Description:

***********************************************************************
**Runningwiththefollowingparameters**
***********************************************************************

ESALESAA.rpt(25%)

Youcanpress[Enter]tomoveonelineatatime,orpress[Space]tomoveapageatatime.Gotothebottomofthereport.

Host01Linux

***********************************************************************
***RunTimeStatistics***
***********************************************************************

Reportat2012091919:42:10(activitysince2012091919:27:05)

Outputto./dirdat/aa:

FromTableOGGUSER1.TCUSTMER:
#inserts:5
#updates:1
#deletes:0
#discards:0
FromTableOGGUSER1.TCUSTORD:
#inserts:5
#updates:3
#deletes:2
#discards:0

***********************************************************************
**RunTimeWarnings**
***********************************************************************

GGSCI(host01)4>

YoucandothesamethingtoviewtheDataPumppsalesabreport.

2. Viewtheprocessreportsforthetarget.

Onthetargethost02,viewtheprocessreportsfortheReplicat.(Forsomethingastrivialasthis,youdonotneedtorunObey
startup.oby,thoughitcouldn'thurt.)

Host02Linux

[oggadm2@host02ogg02]$./ggsci
GGSCI(host02)>SendReplicatrsalesab,Report

SendingREPORTrequesttoREPLICATRSALESAB...
Requestprocessed.

GGSCI(host02)>ViewReportrsalesab
***********************************************************************
OracleGoldenGateDeliveryforOracle
Version11.2.1.0.314400833OGGCORE_11.2.1.0.3_PLATFORMS_120823.1258_FBO
Linux,x64,64bit(optimized),Oracle11gonAug23201220:37:31
Copyright(C)1995,2012,Oracleand/oritsaffiliates.Allrightsreserved.

Startingat2012091919:49:13
***********************************************************************

OperatingSystemVersion:Linux
Version#1SMPWedJul2721:02:33EDT2011,Release2.6.32200.13.1.el5uek
Node:host02.example.com
Machine:x86_64
softlimithardlimit
AddressSpaceSize:unlimitedunlimited
HeapSize:unlimitedunlimited
FileSize:unlimitedunlimited
CPUTime:unlimitedunlimited

Processid:23557

Description:

***********************************************************************
**Runningwiththefollowingparameters**
***********************************************************************
***********************************************************************

More(25%)

Youcanpress[Enter]tomoveonelineatatime,orpress[Space]tomoveapageatatime.Gotothebottomofthereport.

Host02Linux

***********************************************************************
***RunTimeStatistics***
***********************************************************************

Lastrecordforthelastcommittedtransactionisthefollowing:
___________________________________________________________________
Trailname:./dirdat/ab000000
HdrInd:E(x45)Partition:.(x04)
UndoFlag:.(x00)BeforeAfter:B(x42)
RecLength:61(x003d)IOTime:2012092002:04:41.000792
IOType:3(x03)OrigNode:255(xff)
TransInd:.(x02)FormatType:R(x52)
SyskeyLen:0(x00)Incomplete:.(x00)
AuditRBA:20AuditPos:6237080
Continued:N(x00)RecCount:1(x01)

2012092002:04:41.000792DeleteLen61RBA3775
Name:OGGUSER1.TCUSTORD
___________________________________________________________________

Reading./dirdat/ab000000,currentRBA3932,16records

Reportat2012092014:04:52(activitysince2012091919:49:15)

FromTableOGGUSER1.TCUSTMERtoOGGUSER2.TCUSTMER:
#inserts:5
#updates:1
#deletes:0
#discards:0
FromTableOGGUSER1.TCUSTORDtoOGGUSER2.TCUSTORD:
#inserts:5
#updates:3
#deletes:2
#discards:0

***********************************************************************
**RunTimeWarnings**
***********************************************************************

GGSCI(host02)>

Thecountofinserts/updates/deletesfortheReplicatshouldmatchthenumberfortheExtract.Iftherewereanydiscards,theyshould
beexaminedforthereasonwhytheywerediscarded.

Reportsaregeneratedwhenyouaskforareporttobesent(asyoujustdid),orwhenaprocessstops.Reportsarenamed/numbered
processname.rptforthemostcurrentone,andthenprocessname0.rpt,processname1.rpt,processname2.rptforthemostrecent,upto
processname9.rptfortheoldest.Aseachnewreportiscreated,alltheoldreports"movedownone"gettingrenamed/renumbereduntilthe
oldestisdiscarded.Nomorethan11(themostrecentwithnonumberandtheprevious09)arekeptatatime.

6.2ViewingStatistics
1. ViewstatisticsforthesourceExtract.

Host01Linux

GGSCI(host01)>SendExtractesalesaa,Stats

SendingSTATSrequesttoEXTRACTESALESAA...

StartofStatisticsat2012092014:08:06.

Outputto./dirdat/aa:

ExtractingfromOGGUSER1.TCUSTMERtoOGGUSER1.TCUSTMER:

***Totalstatisticssince2012091919:27:05***
Totalinserts5.00
Totalupdates1.00
Totaldeletes0.00
Totaldiscards0.00
Totaloperations6.00

***Dailystatisticssince2012092000:00:00***
Totalinserts3.00
Totalupdates1.00
Totaldeletes0.00
Totaldiscards0.00
Totaloperations4.00
***Hourlystatisticssince2012092014:00:00***

Nodatabaseoperationshavebeenperformed.

***Lateststatisticssince2012091919:27:05***
Totalinserts5.00
Totalupdates1.00
Totaldeletes0.00
Totaldiscards0.00
Totaloperations6.00

ExtractingfromOGGUSER1.TCUSTORDtoOGGUSER1.TCUSTORD:

***Totalstatisticssince2012091919:27:05***
Totalinserts5.00
Totalupdates3.00
Totaldeletes2.00
Totaldiscards0.00
Totaloperations10.00

***Dailystatisticssince2012092000:00:00***
Totalinserts3.00
Totalupdates3.00
Totaldeletes2.00
Totaldiscards0.00
Totaloperations8.00

***Hourlystatisticssince2012092014:00:00***

Nodatabaseoperationshavebeenperformed.

***Lateststatisticssince2012091919:27:05***
Totalinserts5.00
Totalupdates3.00
Totaldeletes2.00
Totaldiscards0.00
Totaloperations10.00

EndofStatistics.

GGSCI(host01)>

ThecommandStatsesalesaadoesthesamething.Iftheprocessstopsforanyreason,allstatisticsarelost.

2. ViewstatisticsforthetargetReplicat.

Host02Linux

GGSCI(host02)>SendReplicatrsalesab,Stats

SendingSTATSrequesttoREPLICATRSALESAB...

StartofStatisticsat2012092014:10:51.

ReplicatingfromOGGUSER1.TCUSTMERtoOGGUSER2.TCUSTMER:

***Totalstatisticssince2012091919:49:15***
Totalinserts5.00
Totalupdates1.00
Totaldeletes0.00
Totaldiscards0.00
Totaloperations6.00

***Dailystatisticssince2012092000:00:00***
Totalinserts3.00
Totalupdates1.00
Totaldeletes0.00
Totaldiscards0.00
Totaloperations4.00

***Hourlystatisticssince2012092014:00:00***

Nodatabaseoperationshavebeenperformed.

***Lateststatisticssince2012091919:49:15***
Totalinserts5.00
Totalupdates1.00
Totaldeletes0.00
Totaldiscards0.00
Totaloperations6.00

ReplicatingfromOGGUSER1.TCUSTORDtoOGGUSER2.TCUSTORD:

***Totalstatisticssince2012091919:49:15***
Totalinserts5.00
Totalupdates3.00
Totaldeletes2.00
Totaldiscards0.00
Totaloperations10.00
***Dailystatisticssince2012092000:00:00***
Totalinserts3.00
Totalupdates3.00
Totaldeletes2.00
Totaldiscards0.00
Totaloperations8.00

***Hourlystatisticssince2012092014:00:00***

Nodatabaseoperationshavebeenperformed.

***Lateststatisticssince2012091919:49:15***
Totalinserts5.00
Totalupdates3.00
Totaldeletes2.00
Totaldiscards0.00
Totaloperations10.00

EndofStatistics.

GGSCI(host02)>

NoticethatpreviouslythestatisticsfortheprimaryExtractwerefromschemaOGGUSER1toOGGUSER1sinceaDataPumpwasinvolved
(stayedlocaltothesourcehost).HereintheReplicatitisclearerthatitisfromschemaOGGUSER1toOGGUSER2.

Thereareotherkindsofstatisticsthatareavailableaswell.

6.3StoppingandDeletingProcesses
1. Donotdothisyet,butifyoueverneededtostopanindividualprocess,yousimplyenterStopExtractesalesaa,orStop*tostop
allofthemonahost.Obviouslyyouwouldreplaceesalesaawiththeprocessnameyouwishtostop.

2. Donotdothisyet,butifyoueverneededtodeleteanindividualprocess,youmustfirstmakesureyouareconnectedtothedatabase
(DBLogin)andyouenterDeleteExtractesalesaa,orDeleteER*todeleteallofthemonahost.GGSCIwillpromptyou,"Are
yousure?"andyousay,y.Youcaneliminatethequestionbyappendinganexclamationpointtotheendofthecommand.For
example,DeleteER*!assumestheansweris"yes."

7.ConfiguringBidirectionalSupport

Youshouldhaveunidirectionalreplicationworkingalready.Atthesimplestimplementation,bidirectionalreplicationisjusttwounrelated
unidirectionalreplications.So,adoptingthenaming/numberingconventionfromtheOverview,onedirectionwillbethe"sales"setoffilesfrom"a"to
"b"(esalesaa,psalesab,dsalesab,rsalesab),andtheotherdirectionwillbethe"sales"setoffilesfrom"b"to"a"(esalesbb,psalesba,
dsalesba,rsalesba).Toconfigurebidirectionalreplicationsupport,performthefollowingsteps:

7.1ConfiguringExtract
1. Onsourcehost02,createtheprimaryExtractparameterfile.ThisisalmostanexactrepeatofTopic3.1.1.Seethatsectionfor
additionalnotes.

Host02Linux

[oggadm2@host02ogg02]./ggsci
OracleGoldenGateCommandInterpreterforOracle
...manylinesomittedforclarity...

GGSCI(host02)1>Obeystartup.oby

...manylinesomittedforclarity...

GGSCI(host02)>EditParamesalesbb
PrimaryExtractfromhost02tohost01
CreatedbyJoeAdminon10/11/2012
SETENV(ORACLE_SID="orcl02")
Extractesalesbb
ExtTrail./dirdat/bb
UserIDoggadm2@orcl02,Passwordpswd2a
TranLogOptionsExcludeUseroggadm2
Tableogguser2.tcust*

GGSCI(host02)>

ThedifferencebetweenthisExtractparameterfileandtheoneonhost01(otherthantheobviousnamechanges)isthat
TranLogOptionsisnowactive(uncommented).

2. CreatetheExtractgroupandthelocalExtracttrailfile.

Host02Linux

GGSCI(host02)>AddExtractesalesbb,TranLog,BeginNow
EXTRACTadded.

GGSCI(host02)>AddExtTrail./dirdat/bb,Extractesalesbb,Megabytes5
GGSCI(host02)>AddExtTrail./dirdat/bb,Extractesalesbb,Megabytes5
EXTTRAILadded.

GGSCI(host02)>

3. CreatethesecondaryExtract(datapump)parameterfile.ThisisalmostanexactrepeatofTopic3.2.1.Seethatsectionforadditional
notes.

Host02Linux

GGSCI(host02)>EditParampsalesba
Datapump(secondaryExtract)fromhost02toHost01
CreatedbyJoeAdminon10/11/2012
Extractpsalesba
RmtHosthost01,MgrPort15001,Compress
RmtTrail./dirdat/ba
Passthru
Tableogguser2.tcust*

GGSCI(host02)>

4. CreatethedatapumpgroupandtheremoteExtracttrailfile.

Host02Linux

GGSCI(host02)>AddExtractpsalesba,ExtTrailSource./dirdat/bb
EXTRACTadded.

GGSCI(host02)>AddRmtTrail./dirdat/ba,Extractpsalesba,Megabytes5
RMTTRAILadded.

GGSCI(host02)>

5. MakesuretheExtractprocesseswerecreatedandregisteredcorrectly.ThisisalmostanexactrepeatofTopic3.3.1.Seethatsection
foradditionalnotes.

Host02Linux

GGSCI(host02)>InfoAll

ProgramStatusGroupLagatChkptTimeSinceChkpt

MANAGERRUNNING
EXTRACTSTOPPEDESALESBB00:00:0000:03:35
EXTRACTSTOPPEDPSALESBA00:00:0000:00:15
REPLICATRUNNINGRSALESAB00:00:0000:00:05

GGSCI(host02)>

YouhavesuccessfullyconfiguredtheExtractfromhost02tohost01(thereturnpathofthebidirectionalsolution).

7.2ConfiguringReplicat
1. Ontargethost01,createtheReplicatparameterfile.ThisisalmostanexactrepeatofTopic4.1.1.

Host01Linux

[oggadm1@host01ogg01]$./ggsci
OracleGoldenGateCommandInterpreterforOracle
...manylinesomittedforclarity...

GGSCI(host01)1>Obeystartup.oby

...manylinesomittedforclarity...butmakesureeverythingstarted.

GGSCI(host01)>EditParamrsalesba
Deliveryfromhost02tohost01
CreatedbyJoeAdminon10/11/2012
Replicatrsalesba
UserIDoggadm1@orcl01,passwordpswd1a
AssumeTargetDefs
SourceDefsdirdef/dsalesab.def
DiscardFiledirrpt/rsalesba.dsc,Append
Mapogguser2.tcustmer,Targetogguser1.tcustmer
Mapogguser2.*,Targetogguser1.*

GGSCI(host01)>

YoucoulddefineandcopytheSourceDefsagainfromhost02tohost01,butsincetheyhappentobethesametablestructures,you
canuseAssumeTargetDefs.Infact,youcouldhaveusedAssumeTragetDefsinrsalesabaswell.
canuseAssumeTargetDefs.Infact,youcouldhaveusedAssumeTragetDefsinrsalesabaswell.

2. CreatetheReplicatprocess.

Host01Linux

GGSCI(host01)>AddReplicatrsalesba,ExtTrail./dirdat/ba
REPLICATadded.

GGSCI(host01)>

3. FixtheexistingExtractprocesstoacocmodatebidirectionalreplication.PreventloopbackswiththeExcludeUserfeature.

Uncommentthelinethatenablesthisfeature.Thismatchesthesamethinghost02.

Host01Linux

GGSCI(host01)>Stopesalesaa

SendingSTOPrequesttoEXTRACTESALESAA...
Requestprocessed.

GGSCI(host01)>editparamesalesaa
PrimaryExtractfromhost01tohost02
CreatedbyJoeAdminon10/11/2012
SETENV(ORACLE_SID="orcl01")
Extractesalesaa
ExtTrail./dirdat/aa
UserIDoggadm1@orcl01,Passwordpswd1a
TranLogOptionsExcludeUseroggadm1
Tableogguser1.tcust*;

GGSCI(host01)>

4. MakesuretheReplicatprocesswascreatedandregisteredcorrectly.

Host01Linux

GGSCI(host01)>InfoAll

ProgramStatusGroupLagatChkptTimeSinceChkpt

MANAGERRUNNING
EXTRACTSTOPPEDESALESAA00:00:0000:04:22
EXTRACTRUNNINGPSALESAB00:00:0000:00:02
REPLICATSTOPPEDRSALESBA00:00:0000:06:57

GGSCI(host01)>

ItisokayfortheTimeSinceChkpttoexceed10secondsiftheStatusisSTOPPED,butiftheStatusisRUNNINGthenthetime
shouldbelessthan10seconds.

5. Startallprocessesonthetargethost01.

Host01Linux

GGSCI(host01)>Start*

SendingSTARTrequesttoMANAGER...
EXTRACTESALESAAstarting
EXTRACTPSALESABisalreadyrunning.

SendingSTARTrequesttoMANAGER...
REPLICATRSALESBAstarting

GGSCI(host01)>InfoAll

ProgramStatusGroupLagatChkptTimeSinceChkpt

MANAGERRUNNING
EXTRACTRUNNINGESALESAA00:00:0000:00:00
EXTRACTRUNNINGPSALESAB00:00:0000:00:02
REPLICATRUNNINGRSALESBA00:00:0000:00:01

GGSCI(host01)>Exit
[oggadm1@host01ogg01]

6. Startallprocessesonthesourcehost02.

Host02Linux

GGSCI(host02)>Start*

SendingSTARTrequesttoMANAGER...
SendingSTARTrequesttoMANAGER...
EXTRACTESALESBBstarting

SendingSTARTrequesttoMANAGER...
EXTRACTPSALESBAstarting
REPLICATRSALESABisalreadyrunning.

GGSCI(host02)>InfoAll

ProgramStatusGroupLagatChkptTimeSinceChkpt

MANAGERRUNNING
EXTRACTRUNNINGESALESBB00:00:0000:00:01
EXTRACTRUNNINGPSALESBA00:00:0000:00:02
REPLICATRUNNINGRSALESAB00:00:0000:00:04

GGSCI(host02)>

AllExtractandReplicatprocessesareconfiguredandstartedfromhost02tohost01.TheearlierExtractandreplicatfromhost01tohost02are
stillrunning.

7.3GeneratingTraffic
1. INSERTanewrowonhost01.

Host01Linux

[oggadm1@host01ogg01]sqlplusogguser1@orcl01/pswd1u
SQL>INSERTINTOtcustmerVALUES('WHIZ','WHIZBANGCORP','HOSTA','AA')
1rowcreated.

SQL>SELECT*FROMtcustmer

CUSTNAMECITYST

DAVEDAVE'SPLANESINC.TALLAHASSEEFL
BILLBILL'SUSEDCARSDENVERCO
ANNANN'SBOATSNEWYORKNY
WHIZWHIZBANGCORPHOSTAAA
WILLBGSOFTWARECO.SEATTLEWA
JANEROCKYFLYERINC.DENVERCO

6rowsselected.

SQL>commit
Commitcomplete.

SQL>exit
[oggadm1@host01ogg01]

MakesuretheGGSCIprocessesarestillrunningonhost02.

Host02Linux

GGSCI(host02)>InfoAll

ProgramStatusGroupLagatChkptTimeSinceChkpt

MANAGERRUNNING
EXTRACTRUNNINGESALESBB00:00:0000:00:05
EXTRACTRUNNINGPSALESBA00:00:0000:00:05
REPLICATRUNNINGRSALESAB00:00:0000:00:06

GGSCI(host02)>

VerifythattheWhizbangrowwasreplicatedtohost02.

Host02Linux

GGSCI(host02)>Exit
[oggadm2@host02ogg02]sqlplusogguser2@orcl02/pswd2u
SQL>SELECT*FROMtcustmer

CUSTNAMECITYST

WILLBGSOFTWARECO.SEATTLEWA
JANEROCKYFLYERINC.DENVERCO
DAVEDAVE'SPLANESINC.TALLAHASSEEFL
BILLBILL'SUSEDCARSDENVERCO
ANNANN'SBOATSNEWYORKNY
WHIZWHIZBANGCORPHOSTAAA

6rowsselected.
SQL>

Donotworryiftheroworderisdifferent.LeaveSQL*Plusrunningforthenextstep.

2. INSERTanewrowonhost02.

Host02Linux

SQL>INSERTINTOtcustmerVALUES('FOO','FOOBARINC','HOSTB','CC')
1rowcreated.

SQL>SELECT*FROMtcustmer

CUSTNAMECITYST

WILLBGSOFTWARECO.SEATTLEWA
JANEROCKYFLYERINC.DENVERCO
DAVEDAVE'SPLANESINC.TALLAHASSEEFL
BILLBILL'SUSEDCARSDENVERCO
ANNANN'SBOATSNEWYORKNY
WHIZWHIZBANGCORPHOSTAAA
FOOFOOBARINCHOSTBCC

7rowsselected.

SQL>commit
Commitcomplete.

SQL>exit
[oggadm2@host02ogg02]

MakesuretheGGSCIprocessesarestillrunningonhost02.

Host02Linux

[oggadm2@host02ogg02]./ggsci
GGSCI(host02)>InfoAll

ProgramStatusGroupLagatChkptTimeSinceChkpt

MANAGERRUNNING
EXTRACTRUNNINGESALESBB00:00:0000:00:06
EXTRACTRUNNINGPSALESBA00:00:0000:00:03
REPLICATRUNNINGRSALESAB00:00:0000:00:04

GGSCI(host02)>

VerifythattheFoobarrowwasreplicatedtohost01.

Host01Linux

[oggadm1@host01ogg01]sqlplusogguser1@orcl01/pswd1u
SQL>SELECT*FROMtcustmer

CUSTNAMECITYST

DAVEDAVE'SPLANESINC.TALLAHASSEEFL
BILLBILL'SUSEDCARSDENVERCO
ANNANN'SBOATSNEWYORKNY
WHIZWHIZBANGCORPHOSTAAA
FOOFOOBARINCHOSTBCC
WILLBGSOFTWARECO.SEATTLEWA
JANEROCKYFLYERINC.DENVERCO

7rowsselected.

SQL>exit
[oggadm1@host01ogg01]

Bothhost01andhost02shouldhavethesamerows.(Ifyouarecurious,thereasontheroworderisdifferentisbecausethetworows
youinsertedwentintothe"holes"leftbyearlierdeletesandrollbacksthatnevergotreplicated.)

Thisdoesnottakeintoaccountthepossibilityofcollisiondetectionandresolution(CDR),whichisbeyondthescopeofthisOBE.

Summary

OracleGoldenGatecandofarmorethanwasdemonstratedinthissimpleexercise.

Inthistutorial,youhavelearnedhowto:

InstallandconfiguretheOracleGoldenGatesoftware
ConfigureandstartExtract,DataPump,andReplicatprocesses
Generatesampledataandtestthevalidityofthereplication
Generatesampledataandtestthevalidityofthereplication
Managethereportsproducedbytheprocesses

Resources

Helptopicsrelevanttothetopicofthistutorial:

OracleGoldenGateProductDocumentationversion11.2.1(E3520901)andotherolderversions
CoursesfromOracleUniversity
ExternalWebsitesforrelatedinformation
TolearnmoreaboutOracleGoldenGate,refertoadditionalOBEsintheOracleLearningLibrary

Credits

LeadCurriculumDeveloper:SteveFriedberg.
OtherContributors:RichardJohnston,HadiKoesnodihardjo,SimonWhitworth,JoedeBuzna,ChrisLawless.

Вам также может понравиться