Duplicating a Database with Recovery Manager.docx
《Duplicating a Database with Recovery Manager.docx》由会员分享,可在线阅读,更多相关《Duplicating a Database with Recovery Manager.docx(28页珍藏版)》请在冰点文库上搜索。
DuplicatingaDatabasewithRecoveryManager
DuplicatingaDatabasewithRecoveryManager
ThischapterdescribeshowtousetheDUPLICATEcommandtocreateaduplicatedatabasefortestingpurposes.Thischaptercontainsthesetopics:
∙CreatingaDuplicateDatabase:
Overview
∙GeneratingFilesfortheDuplicateDatabase
∙PreparingtheAuxiliaryInstanceforDuplication:
BasicSteps
∙CreatingaDuplicateDatabaseonaLocalorRemoteHost
∙DatabaseDuplicationExamples
SeeAlso:
OracleDataGuardConceptsandAdministrationtolearnhowtocreateastandbydatabasewiththeDUPLICATEcommand
CreatingaDuplicateDatabase:
Overview
YoucanusetheRMANDUPLICATEcommandtocreateaduplicatedatabasefromtargetdatabasebackupswhilestillretainingtheoriginaltargetdatabase.Theduplicatedatabasecanbeidenticaltotheoriginaldatabaseorcontainonlyasubsetoftheoriginaltablespaces.
Aduplicatedatabaseisacopyofatargetdatabasethatyoucanrunindependentlyforavarietyofpurposes.Forexample,youcanuseitto:
∙Testbackupandrecoveryprocedures
∙Exportdatasuchasatablethatwasinadvertentlydroppedfromtheproductiondatabase,andthenimportitbackintotheproductiondatabase
Forexample,youcanduplicatetheproductiondatabaseonhost1tohost2,andthenusetheduplicatedatabaseonhost2topracticerestoreandrecoveryscenarioswhiletheproductiondatabaseonhost1continuesasusual.
Aduplicatedatabaseisdistinctfromastandbydatabase,althoughbothtypesofdatabasesarecreatedwiththeDUPLICATEcommand.Astandbydatabaseisacopyoftheprimarydatabasethatyoucanupdatecontinuallyorperiodicallywitharchivedlogsfromtheprimarydatabase.Iftheprimarydatabaseisdamagedordestroyed,thenyoucanperformfailovertothestandbydatabaseandeffectivelytransformitintothenewprimarydatabase.Aduplicatedatabase,ontheotherhand,cannotbeusedinthisway:
itisnotintendedforfailoverscenariosanddoesnotsupportthevariousstandbyrecoveryandfailoveroptions.
SeeAlso:
OracleDataGuardConceptsandAdministrationtolearnhowtocreateastandbydatabasewiththeDUPLICATEcommand
HowRecoveryManagerDuplicatesaDatabase
Topreparefordatabaseduplication,youmustfirstcreateanauxiliaryinstanceasdescribedin"PreparingtheAuxiliaryInstanceforDuplication:
BasicSteps".Fortheduplicationtowork,youmustconnectRMANtoboththetarget(primary)databaseandanauxiliaryinstancestartedinNOMOUNTmode.
Youmusthaveatleastoneauxiliarychannelallocatedontheauxiliaryinstance.Theprincipalworkoftheduplicationisperformedbytheauxiliarychannel,whichstartsaserversessionontheduplicatehost.Thischannelthenrestoresthenecessarybackupsoftheprimarydatabase,usesthemtocreatetheduplicatedatabase,andinitiatesrecovery.
SolongasRMANisabletoconnecttotheprimaryandauxiliaryinstances,theRMANclientcanrunonanymachine.However,allbackupsandarchivedlogsusedforcreatingandrecoveringtheduplicatedatabasemustbeaccessiblebytheserversessionontheduplicatehost.Iftheduplicatehostisnotthesameastheprimaryhost,thenyoumustmakebackupsondiskontheprimaryhostavailabletotheduplicatehostwiththesamefullpathnameasintheprimarydatabase.Whenusingdiskbackups,youcanaccomplishthisgoalinanyofthefollowingways:
∙Manuallytransferthebackupsfromtheprimaryhosttotheremotehosttoanidenticalpath.
∙Manuallytransferthebackupsfromtheprimaryhosttotheremotehosttoanewpath,andthenruntheCATALOGcommandtoaddthesecopiestotheRMANrepository.
∙UseNFSorshareddisksandmakesurethatthesamepathisaccessibleintheremotehost.
Whenusingtapebackups,youmustmakethetapescontainingthebackupsaccessibletotheremotenode,eitherbyphysicallymovingthetapetotheremotehostorbymeansofanetworktapeserver.
Aspartoftheduplicatingoperation,RMANautomatesthefollowingsteps:
∙Createsacontrolfilefortheduplicatedatabase
∙Restoresthetargetdatafilestotheduplicatedatabaseandperformsincompleterecoverybyusingallavailableincrementalbackupsandarchivedlogs
∙Shutsdownandstartstheauxiliaryinstance(referto"Task4:
StarttheAuxiliaryInstance"forissuesrelatingtoclient-sideversusserver-sideinitializationparameterfiles)
∙OpenstheduplicatedatabasewiththeRESETLOGSoptionafterincompleterecoverytocreatetheonlineredologs(exceptwhenrunningDUPLICATE...FORSTANDBY,inwhichcaseRMANdoesnotopenthedatabase)
∙Generatesanew,uniqueDBIDfortheduplicatedatabase(exceptwhenyoucreateastandbydatabasewithDUPLICATE...FORSTANDBY,inwhichcaseRMANdoesnotcreateauniqueDBID)
Duringduplication,RMANmustperformincompleterecoverybecausetheonlineredologsinthetargetarenotbackedupandcannotbeappliedtotheduplicatedatabase.ThefarthestthatRMANcangoinrecoveryoftheduplicatedatabaseisthemostrecentredologarchivedbythetargetdatabase.
SeeAlso:
OracleDataGuardConceptsandAdministrationtolearnhowtocreateastandbydatabasewithRMAN
DatabaseDuplicationOptions
Whenduplicatingadatabase,youhavethefollowingoptions:
∙YoucanruntheDUPLICATEcommandwithorwithoutarecoverycatalog
∙Youcanskipread-onlytablespaceswiththeSKIPREADONLYclause.Read-onlytablespacesareincludedbydefault.Ifyouomitthem,thenyoucanaddthemlater.
∙YoucanexcludetablespacesfromtheduplicatedatabasewiththeSKIPTABLESPACEclause.YoucanexcludeanytablespaceexcepttheSYSTEMtablespaceortablespacescontainingrollbackorundosegments.
∙Youcancreatetheduplicatedatabaseinanewhost.Ifthedirectorystructureisthesameonthenewhost,thenyoucanspecifytheNOFILENAMECHECKoptionandreusethetargetdatafilefilenamesfortheduplicatedatafiles.
∙YoucanduplicateatargetdatabaseonatraditionalfilesystemtoanASMorOracleManagedFileslocation.
∙Youcanrecovertheduplicatedatabasetoapastpointintime,usingusetheSETUNTILcommandorDUPLICATE...UNTILcommand.Bydefault,theDUPLICATEcommandcreatestheduplicatedatabasebyusingthemostrecentbackupsofthetargetdatabaseandthenperformsrecoverytothemostrecentconsistentpointcontainedintheincrementalbackupsandarchivedlogs.
∙Youcanregistertheduplicatedatabaseinthesamerecoverycatalogasthetargetdatabase.ThisoptionispossiblebecauseRMANgivestheduplicatedatabaseanew,uniqueDBIDduringduplication.
Note:
Ifyoucopythetargetdatabasebymeansofoperatingsystemutilities,thentheDBIDofthecopieddatabaseremainsthesameastheoriginaldatabase.Toregisterthecopydatabaseinthesamerecoverycatalogwiththeoriginal,youmustchangetheDBIDwiththeDBNEWIDutility(refertoOracleDatabaseUtilities).
∙Insomecases,youcansettheduplicatedatabaseDB_NAMEdifferentlyfromthetargetdatabaseDB_NAME.Morespecifically,iftheduplicatedatabaseexistsinthesameOraclehomeasthetarget,thentheDB_NAMEinitializationparametermustbedifferent.IftheduplicatedatabaseisinadifferentOraclehomefromthetargetdatabase,thentheDB_NAMEsettingfortheduplicatedatabasemustbeuniqueamongdatabasesinitsOraclehome.Thisistruewhetherornottheduplicatedatabaseisonthesamehostasthetarget.
DuplicatingaDatabase:
PrerequisitesandRestrictions
RMANduplicationinvolvesanumberofprerequisites,restrictions,andcaveats.ReviewtherestrictionssectionoftheDUPLICATEcommandintheOracleDatabaseRecoveryManagerReferenceforacompletelist.
GeneratingFilesfortheDuplicateDatabase
Whenduplicatingadatabase,RMANcreatestherequireddatabasefiles.Thissectiondescribesthesestagesoffilecreation:
∙CreatingtheDuplicateControlFiles
∙CreatingtheDuplicateOnlineRedoLogs
∙RenamingDatafilesWhenDuplicatingaDatabase
CreatingtheDuplicateControlFiles
TheDUPLICATEcommandcreatesthecontrolfilesbyusingthenameslistedintheinitializationparameterfileoftheauxiliaryinstance.Whenchoosingnamesfortheduplicatedatabasecontrolfiles,makesurethatyousettheinitializationparametersettingscorrectlysothatyoudonotoverwritetheproductionfilesatthetargetdatabase.
CreatingtheDuplicateOnlineRedoLogs
Table 11-1liststheoptionsforcreatingthenamesoftheduplicateonlineredologs.Theoptionsappearintheorderofprecedence.
Table11-1OrderofPrecedenceforOnlineRedoLogFilenameCreation
Order
Method
Result
1
SpecifytheLOGFILEclauseofDUPLICATEcommand.
Createsonlineredologsasspecified.
2
SetLOG_FILE_NAME_CONVERTinitializationparameter.
Transformstargetfilenames,forexample,fromlog_*toduplog_*.Notethatyoucanspecifymultipleconversionpairs.
Thisparameterallowstheredologtoexistaslongasthesizematches,becauseitusestheREUSEparameterwhencreatingthelogs.
3
Dononeoftheprecedingsteps.
Makestheduplicatefilenamesthesameasthetargetfilenames.YoumustspecifytheNOFILENAMECHECKoptionwhenusingthismethodandtheduplicatedatabaseshouldbeinadifferenthost.
TheorderofprecedencedetermineshowRMANrenamestheonlineredologs.Forexample,ifyouspecifyboththeLOGFILEclauseandtheLOG_FILE_NAME_CONVERTparameter,thenRMANusestheLOGFILEclause.Ifyouspecifyneitherofthefirsttwooptions,thenRMANusestheoriginaltargetredologfilenamesfortheduplicatedatabasefiles.
Caution:
Ifthetargetandduplicatedatabasesareinthesamehost,thendonotusethenameofanonlineredologcurrentlyinusebythetargetdatabase.