Vous êtes sur la page 1sur 8

12cDatabaseUpgrade11.2.0.3to12.1.0.

1upgrade
usingDBUA

Home

EnterpriseManager12cAgentlessAutomaticTarget
Discovery

RestoreRMANbackuptoanotherserverfortestingdisasterrecoveryprocedures
aswellasforcloning
ThisnoteexplainstheprocedureusedtorestoreanOracleSuggestedStrategyincrementalbackuponanotherserver.
Thisisusefulwhenwehavetodoperiodictestingofdisasterrecoveryprocedureswherewesimulateascenariowhen
thecompletedatabaseserverhascrashedandanewserverhasbeenprovisioned.
Butletusassumethatthedirectorystructureonthenewortargetserverisdifferenttothatofthesource
server.
Sointhiscasethebackuphasbeenrestoredtothestaginglocation/home/oracle/stageonthenewserverandallthe
databasefilesarebeingrestoredinadifferentlocationtothatonthesource/home/oracle/sqlfun

RestoretheSPFILE
RMAN>startupnomountforce

startupfailed:ORA01078:failureinprocessingsystemparameters
LRM00109:couldnotopenparameterfile'/u01/app/oracle/product/11.2.0/dbhome_2/dbs/initsq
startingOracleinstancewithoutparameterfileforretrievalofspfile
Oracleinstancestarted
TotalSystemGlobalArea158662656bytes
FixedSize2226456bytes
VariableSize104859368bytes
DatabaseBuffers46137344bytes
RedoBuffers5439488bytes
RMAN>restorespfilefrom'/home/oracle/stage/o1_mf_s_819826669_8x7w7g70_.bkp'
Startingrestoreat04JUL13
usingtargetdatabasecontrolfileinsteadofrecoverycatalog
allocatedchannel:ORA_DISK_1
channelORA_DISK_1:SID=162devicetype=DISK

channelORA_DISK_1:restoringspfilefromAUTOBACKUP/home/oracle/stage/o1_mf_s_819826669_8x
channelORA_DISK_1:SPFILErestorefromAUTOBACKUPcomplete
Finishedrestoreat04JUL13

CreatethePFILEfromSPFILEandmakeparameterchangesasrequired
$sqlplussysassysdba
SQL*Plus:Release11.2.0.3.0ProductiononThuJul409:43:482013
Copyright(c)1982,2011,Oracle.Allrightsreserved.
Enterpassword:
Connectedtoanidleinstance.
SQL>createpfilefromspfile
Filecreated.
Notemakerequiredchangeshereintheinit.orafiletotakecareofnewdirectoriesforcontrolfiles,audit
dump,fastrecoveryareaetc

SQL>createspfilefrompfile
Filecreated.

RestoretheControlFiles
RMAN>restorecontrolfilefrom'/home/oracle/stage/o1_mf_s_819826669_8x7w7g70_.bkp'
Startingrestoreat04JUL13
usingtargetdatabasecontrolfileinsteadofrecoverycatalog
allocatedchannel:ORA_DISK_1
channelORA_DISK_1:SID=134devicetype=DISK
channelORA_DISK_1:restoringcontrolfile
channelORA_DISK_1:restorecomplete,elapsedtime:00:00:01
outputfilename=/home/oracle/sqlfun/control01.ctl
outputfilename=/home/oracle/sqlfun/control02.ctl
Finishedrestoreat04JUL13

Mountthedatabaseandcatalogthebackuppieceswhichhavebeenrestoredinthenewlocation
RMAN>alterdatabasemount
databasemounted
releasedchannel:ORA_DISK_1
RMAN>catalogstartwith'/home/oracle/stage'
Startingimplicitcrosscheckbackupat04JUL13
usingtargetdatabasecontrolfileinsteadofrecoverycatalog
allocatedchannel:ORA_DISK_1
channelORA_DISK_1:SID=134devicetype=DISK
Crosschecked25objects
Finishedimplicitcrosscheckbackupat04JUL13
Startingimplicitcrosscheckcopyat04JUL13
usingchannelORA_DISK_1
Crosschecked10objects
Finishedimplicitcrosscheckcopyat04JUL13
searchingforallfilesintherecoveryarea
catalogingfiles...
catalogingdone

ListofCatalogedFiles
=======================
FileName:/u01/app/oracle/flash_recovery_area/SQLFUN/autobackup/2013_07_04/o1_mf_n_81988414
FileName:/u01/app/oracle/flash_recovery_area/SQLFUN/archivelog/2013_07_04/2013_07_03/o1_mf
FileName:/u01/app/oracle/flash_recovery_area/SQLFUN/archivelog/2013_07_04/2013_07_03/o1_mf
FileName:/u01/app/oracle/flash_recovery_area/SQLFUN/archivelog/2013_07_04/2013_07_03/o1_mf
FileName:/u01/app/oracle/flash_recovery_area/SQLFUN/archivelog/2013_07_04/2013_07_03/o1_mf
FileName:/u01/app/oracle/flash_recovery_area/SQLFUN/archivelog/2013_07_04/2013_07_03/o1_mf
searchingforallfilesthatmatchthepattern/home/oracle/stage
ListofFilesUnknowntotheDatabase
=====================================
FileName:/home/oracle/stage/o1_mf_sysaux_7zpgb1hd_.dbf
FileName:/home/oracle/stage/o1_mf_nnnd1_ORA_OEM_LEVEL_0_8x7w6zcb_.bkp
FileName:/home/oracle/stage/o1_mf_nnnd1_ORA_OEM_LEVEL_0_8x7w76jv_.bkp

FileName:/home/oracle/stage/o1_mf_nnnd1_ORA_OEM_LEVEL_0_8x7w76jv_.bkp
FileName:/home/oracle/stage/o1_mf_undotbs1_7zpgck9f_.dbf
FileName:/home/oracle/stage/o1_mf_nnnd1_ORA_OEM_LEVEL_0_8x7w65l9_.bkp
FileName:/home/oracle/stage/o1_mf_example_7zgkdp6p_.dbf
FileName:/home/oracle/stage/o1_mf_threaten_7zpgbyck_.dbf
FileName:/home/oracle/stage/o1_mf_users_7zpgcnno_.dbf
FileName:/home/oracle/stage/o1_mf_s_819826669_8x7w7g70_.bkp
FileName:/home/oracle/stage/o1_mf_index_da_7zgkcz04_.dbf
FileName:/home/oracle/stage/o1_mf_example__7zpgcg0x_.dbf
FileName:/home/oracle/stage/o1_mf_system_7zpgbh79_.dbf
FileName:/home/oracle/stage/o1_mf_nnnd1_ORA_OEM_LEVEL_0_8x7w7b0f_.bkp
Doyoureallywanttocatalogtheabovefiles(enterYESorNO)?YES
catalogingfiles...
catalogingdone
ListofCatalogedFiles
=======================
FileName:/home/oracle/stage/o1_mf_sysaux_7zpgb1hd_.dbf
FileName:/home/oracle/stage/o1_mf_nnnd1_ORA_OEM_LEVEL_0_8x7w6zcb_.bkp
FileName:/home/oracle/stage/o1_mf_nnnd1_ORA_OEM_LEVEL_0_8x7w76jv_.bkp
FileName:/home/oracle/stage/o1_mf_undotbs1_7zpgck9f_.dbf
FileName:/home/oracle/stage/o1_mf_nnnd1_ORA_OEM_LEVEL_0_8x7w65l9_.bkp
FileName:/home/oracle/stage/o1_mf_example_7zgkdp6p_.dbf
FileName:/home/oracle/stage/o1_mf_threaten_7zpgbyck_.dbf
FileName:/home/oracle/stage/o1_mf_users_7zpgcnno_.dbf
FileName:/home/oracle/stage/o1_mf_s_819826669_8x7w7g70_.bkp
FileName:/home/oracle/stage/o1_mf_index_da_7zgkcz04_.dbf
FileName:/home/oracle/stage/o1_mf_example__7zpgcg0x_.dbf
FileName:/home/oracle/stage/o1_mf_system_7zpgbh79_.dbf
FileName:/home/oracle/stage/o1_mf_nnnd1_ORA_OEM_LEVEL_0_8x7w7b0f_.bkp

GeneratetheSETNEWNAMEFORDATAFILEcommand
Note:
SincetheOSSbackupimagecopyisbasedonOracleManagedFileformat(OMF),Ifindthiserroreventhoughwe
havesettheDB_FILE_NAME_CONVERTparametertoaccountforthedirectorypathchangebetweensourceand
target.
RMANisnotrestoringthedatafilesinthenewlocationbutislookingforthedirectorypathwhichexistedonthesource
database,butwhichisnotpresentonthenewortargetserverwherewearedoingtherestore.

RMAN>restoredatabase
Startingrestoreat04JUL13
usingchannelORA_DISK_1
channelORA_DISK_1:restoringdatafile00001
inputdatafilecopyRECID=3060STAMP=819884997filename=/home/oracle/stage/o1_mf_system_7zpgbh79_.dbf
destinationforrestoreofdatafile00001:/u01/app/oracle/oradata/sqlfun/system01.dbf
ORA19504:failedtocreatefile/u01/app/oracle/oradata/sqlfun/system01.dbf
ORA27040:filecreateerror,unabletocreatefile
Linuxx86_64Error:2:Nosuchfileordirectory
Additionalinformation:1
ORA19600:inputfileisdatafilecopy3060(/home/oracle/stage/o1_mf_system_7zpgbh79_.dbf)
ORA19601:outputfileisdatafile1(/u01/app/oracle/oradata/sqlfun/system01.dbf)

SotoworkaroundthiswewillgenerateatextfileviaSQL*PLUSwhichwillcontaintheSETNEWNAMEcommands
andcallthisfilefromRMAN.
Thesearethecontentsofthetextfilerename_files.sql

Thesearethecontentsofthetextfilerename_files.sql
setheadoffpages0feedoffechooffverifyoff
setlines200
spoolrename_datafiles.lst
selectSETNEWNAMEFORDATAFILE||FILE#||TO||/home/oracle/sqlfun/||substr(name,instr(name,/,1)+1)
||fromv$datafile
spooloff
exit
$sqlplussysassysdba
SQL*Plus:Release11.2.0.3.0ProductiononThuJul409:52:442013
Copyright(c)1982,2011,Oracle.Allrightsreserved.
Enterpassword:
Connectedto:
OracleDatabase11gEnterpriseEditionRelease11.2.0.3.064bitProduction
WiththePartitioning,OLAP,DataMiningandRealApplicationTestingoptions
SQL>@rename_files.sql
SETNEWNAMEFORDATAFILE1TO'/home/oracle/sqlfun/system01.dbf'
SETNEWNAMEFORDATAFILE2TO'/home/oracle/sqlfun/sysaux01.dbf'
SETNEWNAMEFORDATAFILE3TO'/home/oracle/sqlfun/undotbs01.dbf'
SETNEWNAMEFORDATAFILE4TO'/home/oracle/sqlfun/users01.dbf'
SETNEWNAMEFORDATAFILE5TO'/home/oracle/sqlfun/threatened_fauna_data.dbf'
SETNEWNAMEFORDATAFILE6TO'/home/oracle/sqlfun/example_temp01.dbf'
SETNEWNAMEFORDATAFILE7TO'/home/oracle/sqlfun/EXAMPLE_5'
SETNEWNAMEFORDATAFILE8TO'/home/oracle/sqlfun/INDEX_DATA_6'

RestoreandRecoverthedatabase
NowpassthisfilenametotheRMANrunblock
RMAN>run{
2>@rename_datafiles.lst
3>SETNEWNAMEFORDATAFILE1TO'/home/oracle/sqlfun/system01.dbf'
4>SETNEWNAMEFORDATAFILE2TO'/home/oracle/sqlfun/sysaux01.dbf'
5>SETNEWNAMEFORDATAFILE3TO'/home/oracle/sqlfun/undotbs01.dbf'
6>SETNEWNAMEFORDATAFILE4TO'/home/oracle/sqlfun/users01.dbf'
7>SETNEWNAMEFORDATAFILE5TO'/home/oracle/sqlfun/threatened_fauna_data.dbf'
8>SETNEWNAMEFORDATAFILE6TO'/home/oracle/sqlfun/example_temp01.dbf'
9>SETNEWNAMEFORDATAFILE7TO'/home/oracle/sqlfun/EXAMPLE_5'
10>SETNEWNAMEFORDATAFILE8TO'/home/oracle/sqlfun/INDEX_DATA_6'
11>**endoffile**
12>restoredatabase
13>switchdatafileall
14>recoverdatabase
15>}
executingcommand:SETNEWNAME
executingcommand:SETNEWNAME
executingcommand:SETNEWNAME
executingcommand:SETNEWNAME
executingcommand:SETNEWNAME
executingcommand:SETNEWNAME
executingcommand:SETNEWNAME

executingcommand:SETNEWNAME
executingcommand:SETNEWNAME
Startingrestoreat04JUL13
usingtargetdatabasecontrolfileinsteadofrecoverycatalog
allocatedchannel:ORA_DISK_1
channelORA_DISK_1:SID=125devicetype=DISK

channelORA_DISK_1:restoringdatafile00001
inputdatafilecopyRECID=3060STAMP=819884997filename=/home/oracle/stage/o1_mf_system_7zp
destinationforrestoreofdatafile00001:/home/oracle/sqlfun/system01.dbf
channelORA_DISK_1:copieddatafilecopyofdatafile00001
outputfilename=/home/oracle/sqlfun/system01.dbfRECID=3061STAMP=819885296
channelORA_DISK_1:restoringdatafile00002
inputdatafilecopyRECID=3053STAMP=819884997filename=/home/oracle/stage/o1_mf_sysaux_7zp
destinationforrestoreofdatafile00002:/home/oracle/sqlfun/sysaux01.dbf
channelORA_DISK_1:copieddatafilecopyofdatafile00002
outputfilename=/home/oracle/sqlfun/sysaux01.dbfRECID=3062STAMP=819885313
channelORA_DISK_1:restoringdatafile00003
inputdatafilecopyRECID=3054STAMP=819884997filename=/home/oracle/stage/o1_mf_undotbs1_7
destinationforrestoreofdatafile00003:/home/oracle/sqlfun/undotbs01.dbf
channelORA_DISK_1:copieddatafilecopyofdatafile00003
outputfilename=/home/oracle/sqlfun/undotbs01.dbfRECID=3063STAMP=819885321
channelORA_DISK_1:restoringdatafile00004
inputdatafilecopyRECID=3057STAMP=819884997filename=/home/oracle/stage/o1_mf_users_7zpg
destinationforrestoreofdatafile00004:/home/oracle/sqlfun/users01.dbf
channelORA_DISK_1:copieddatafilecopyofdatafile00004
outputfilename=/home/oracle/sqlfun/users01.dbfRECID=3064STAMP=819885322
channelORA_DISK_1:restoringdatafile00005
inputdatafilecopyRECID=3056STAMP=819884997filename=/home/oracle/stage/o1_mf_threaten_7
destinationforrestoreofdatafile00005:/home/oracle/sqlfun/threatened_fauna_data.dbf
channelORA_DISK_1:copieddatafilecopyofdatafile00005
outputfilename=/home/oracle/sqlfun/threatened_fauna_data.dbfRECID=3065STAMP=819885327
channelORA_DISK_1:restoringdatafile00006
inputdatafilecopyRECID=3059STAMP=819884997filename=/home/oracle/stage/o1_mf_example__7
destinationforrestoreofdatafile00006:/home/oracle/sqlfun/example_temp01.dbf
channelORA_DISK_1:copieddatafilecopyofdatafile00006
outputfilename=/home/oracle/sqlfun/example_temp01.dbfRECID=3066STAMP=819885331
channelORA_DISK_1:restoringdatafile00007
inputdatafilecopyRECID=3055STAMP=819884997filename=/home/oracle/stage/o1_mf_example_7z
destinationforrestoreofdatafile00007:/home/oracle/sqlfun/EXAMPLE_5
channelORA_DISK_1:copieddatafilecopyofdatafile00007
outputfilename=/home/oracle/sqlfun/EXAMPLE_5RECID=3067STAMP=819885334
channelORA_DISK_1:restoringdatafile00008
inputdatafilecopyRECID=3058STAMP=819884997filename=/home/oracle/stage/o1_mf_index_da_7
destinationforrestoreofdatafile00008:/home/oracle/sqlfun/INDEX_DATA_6
channelORA_DISK_1:copieddatafilecopyofdatafile00008
outputfilename=/home/oracle/sqlfun/INDEX_DATA_6RECID=3068STAMP=819885339
Finishedrestoreat04JUL13
datafile1switchedtodatafilecopy
inputdatafilecopyRECID=3069STAMP=819885343filename=/home/oracle/sqlfun/system01.dbf
datafile2switchedtodatafilecopy
inputdatafilecopyRECID=3070STAMP=819885343filename=/home/oracle/sqlfun/sysaux01.dbf

datafile3switchedtodatafilecopy
inputdatafilecopyRECID=3071STAMP=819885343filename=/home/oracle/sqlfun/undotbs01.dbf
datafile4switchedtodatafilecopy
inputdatafilecopyRECID=3072STAMP=819885343filename=/home/oracle/sqlfun/users01.dbf
datafile5switchedtodatafilecopy
inputdatafilecopyRECID=3073STAMP=819885343filename=/home/oracle/sqlfun/threatened_faun
datafile6switchedtodatafilecopy
inputdatafilecopyRECID=3074STAMP=819885343filename=/home/oracle/sqlfun/example_temp01.
datafile7switchedtodatafilecopy
inputdatafilecopyRECID=3075STAMP=819885343filename=/home/oracle/sqlfun/EXAMPLE_5
datafile8switchedtodatafilecopy

datafile8switchedtodatafilecopy
inputdatafilecopyRECID=3076STAMP=819885343filename=/home/oracle/sqlfun/INDEX_DATA_6

Startingrecoverat04JUL13
usingchannelORA_DISK_1
channelORA_DISK_1:startingincrementaldatafilebackupsetrestore
channelORA_DISK_1:specifyingdatafile(s)torestorefrombackupset
destinationforrestoreofdatafile00001:/home/oracle/sqlfun/system01.dbf
destinationforrestoreofdatafile00002:/home/oracle/sqlfun/sysaux01.dbf
destinationforrestoreofdatafile00007:/home/oracle/sqlfun/EXAMPLE_5
destinationforrestoreofdatafile00008:/home/oracle/sqlfun/INDEX_DATA_6
channelORA_DISK_1:readingfrombackuppiece/home/oracle/stage/o1_mf_nnnd1_ORA_OEM_LEVEL_0
channelORA_DISK_1:piecehandle=/home/oracle/stage/o1_mf_nnnd1_ORA_OEM_LEVEL_0_8x7w65l9_.bk
channelORA_DISK_1:restoredbackuppiece1
channelORA_DISK_1:restorecomplete,elapsedtime:00:00:03
channelORA_DISK_1:startingincrementaldatafilebackupsetrestore
channelORA_DISK_1:specifyingdatafile(s)torestorefrombackupset
destinationforrestoreofdatafile00003:/home/oracle/sqlfun/undotbs01.dbf
channelORA_DISK_1:readingfrombackuppiece/home/oracle/stage/o1_mf_nnnd1_ORA_OEM_LEVEL_0
channelORA_DISK_1:piecehandle=/home/oracle/stage/o1_mf_nnnd1_ORA_OEM_LEVEL_0_8x7w6zcb_.bk
channelORA_DISK_1:restoredbackuppiece1
channelORA_DISK_1:restorecomplete,elapsedtime:00:00:01
channelORA_DISK_1:startingincrementaldatafilebackupsetrestore
channelORA_DISK_1:specifyingdatafile(s)torestorefrombackupset
destinationforrestoreofdatafile00004:/home/oracle/sqlfun/users01.dbf
destinationforrestoreofdatafile00005:/home/oracle/sqlfun/threatened_fauna_data.dbf
channelORA_DISK_1:readingfrombackuppiece/home/oracle/stage/o1_mf_nnnd1_ORA_OEM_LEVEL_0
channelORA_DISK_1:piecehandle=/home/oracle/stage/o1_mf_nnnd1_ORA_OEM_LEVEL_0_8x7w76jv_.bk
channelORA_DISK_1:restoredbackuppiece1
channelORA_DISK_1:restorecomplete,elapsedtime:00:00:01
channelORA_DISK_1:startingincrementaldatafilebackupsetrestore
channelORA_DISK_1:specifyingdatafile(s)torestorefrombackupset
destinationforrestoreofdatafile00006:/home/oracle/sqlfun/example_temp01.dbf
channelORA_DISK_1:readingfrombackuppiece/home/oracle/stage/o1_mf_nnnd1_ORA_OEM_LEVEL_0
channelORA_DISK_1:piecehandle=/home/oracle/stage/o1_mf_nnnd1_ORA_OEM_LEVEL_0_8x7w7b0f_.bk
channelORA_DISK_1:restoredbackuppiece1
channelORA_DISK_1:restorecomplete,elapsedtime:00:00:01
startingmediarecovery

archivedlogforthread1withsequence33isalreadyondiskasfile/u01/app/oracle/flash_
archivedlogforthread1withsequence34isalreadyondiskasfile/u01/app/oracle/flash_
archivedlogforthread1withsequence35isalreadyondiskasfile/u01/app/oracle/flash_
archivedlogforthread1withsequence36isalreadyondiskasfile/u01/app/oracle/flash_
archivedlogfilename=/u01/app/oracle/flash_recovery_area/SQLFUN/archivelog/2013_07_04/2013
archivedlogfilename=/u01/app/oracle/flash_recovery_area/SQLFUN/archivelog/2013_07_04/2013
archivedlogfilename=/u01/app/oracle/flash_recovery_area/SQLFUN/archivelog/2013_07_04/2013
archivedlogfilename=/u01/app/oracle/flash_recovery_area/SQLFUN/archivelog/2013_07_04/2013
unabletofindarchivedlog
archivedlogthread=1sequence=37
RMAN00571:===========================================================
RMAN00569:===============ERRORMESSAGESTACKFOLLOWS===============
RMAN00571:===========================================================

RMAN03002:failureofrecovercommandat07/04/201309:55:58
RMAN06054:mediarecoveryrequestingunknownarchivedlogforthread1withsequence37and
RMAN>

theerrorcanbeignoredasRMANhasappliedalltheavailablearchivelogfilesandisnowtryingtoapplyanonexistent
archivelogfile.
OpenthedatabasewithRESETLOGS
TheRESETLOGScommandwillfailbecausewedonothavethesamedirectorypathwhichexistedonthesourcefor
theOnlineRedoLogfiles.
Sowecreateascriptwhichwillgeneratethenewonlineredologfilenames.

Sowecreateascriptwhichwillgeneratethenewonlineredologfilenames.
Thesearethecontentsoftherename_logfiles.sqlfile
setheadoffpages0feedoffechooffverifyoff
setlines200
spoolrename_logfiles.lst
selectalterdatabaserenamefile||member||||chr(10)||TO||/home/oracle/sqlfun/||
substr(member,instr(member,/,1)+1)||fromv$logfile
spooloff
exit
$sqlplussysassysdba
SQL*Plus:Release11.2.0.3.0ProductiononThuJul410:05:172013
Copyright(c)1982,2011,Oracle.Allrightsreserved.
Enterpassword:
Connectedto:
OracleDatabase11gEnterpriseEditionRelease11.2.0.3.064bitProduction
WiththePartitioning,OLAP,DataMiningandRealApplicationTestingoptions
SQL>@rename_logfiles.sql
alterdatabaserenamefile'/u01/app/oracle/oradata/sqlfun/redo03.log'
TO'/home/oracle/sqlfun/redo03.log'
alterdatabaserenamefile'/u01/app/oracle/oradata/sqlfun/redo02.log'
TO'/home/oracle/sqlfun/redo02.log'
alterdatabaserenamefile'/u01/app/oracle/oradata/sqlfun/redo01.log'
TO'/home/oracle/sqlfun/redo01.log'

NotewecandoallthisfromtheRMANpromptaswellusingtheRMANSQLcommand.Butforthisexamplewedoit
fromSQL*PLUS
$sqlplussysassysdba
SQL*Plus:Release11.2.0.3.0ProductiononThuJul410:50:442013
Copyright(c)1982,2011,Oracle.Allrightsreserved.
Enterpassword:
Connectedto:
OracleDatabase11gEnterpriseEditionRelease11.2.0.3.064bitProduction
WiththePartitioning,OLAP,DataMiningandRealApplicationTestingoptions
SQL>@rename_logfiles.lst
Databasealtered.
Databasealtered.
Databasealtered.
SQL>alterdatabaseopenresetlogs
Databasealtered.

July5th,2013|Tags:DisasterRecovery,lossofalldatabasefiles,resetlogs,restore,rman,rmanclone|Category:Backup
andRecovery

Vous aimerez peut-être aussi