Sie sind auf Seite 1von 7

28/11/2015

11gRelease2TablespacePointInTimeRecoveryrecoverfromdroppedtablespaceOracleDBATipsandTechniques

11gRMANVirtualPrivateCatalog

Home

RMANRestoreValidateExamples

11gRelease2TablespacePointInTimeRecoveryrecoverfromdroppedtablespace
Oneofthegoodnewfeaturesin11gRelease2isthatitenablesustorecoverfromacaseofadropped
tablespace.TSPITR(tablespacepointintimerecovery)hasbeenaroundinearlierreleases,butwecouldnot
recoveradroppedtablespace.
What11gR2doesisthatitpeformsafullyautomatedRMANmanagedTSPITR.Itcreatesandstartstheauxiliary
instanceandrestoresjustthedatafilesitrequiresSYSTEM,SYSAUX,UNDOandthefilespertainingtothe
droppedtablespaceinthiscasedatafiles1,2,3and7inthelocationwhichwespecifyastheAuxiliary
Destination.ItwillfirstperformarecoveryofthetablespaceontheauxiliaryinstanceandthenuseDataPump
andTransportableTablespacetechnologytoextractandimportthetablespacemetadataintotheoriginalsource
database.
ToillustratethisexamplewecreateanewtablespaceMYEXAMPLEandcreatetwotablesMYSALESand
MYCOSTSinthistablespace.Wetakeadatabasebackupandthendropthetablespaceandthenperform
tablespacepointintimerecoveryusingRMAN.
BeforedroppingthetablespacewefirstnotetheSCNaswewillusethisSCNwhenwedotheTSPITR.Notealso
thatweareconnectedtoaRMANcatalogaswellalthoughthedocumentationdoesstatethatwecanperform
TSPITRwithoutarecoverycatalog.
SQL>createtablespacemyexampledatafile'+DATA'size200m
Tablespacecreated.
SQL>createtablemysales
2tablespacemyexample
3asselect*fromsales
Tablecreated.
SQL>createtablemycosts
2tablespacemyexample
3asselect*fromcosts
Tablecreated.
SQL>conn/assysdba
Connected.
SQL>altersystemswitchlogfile
Systemaltered.
SQL>selectcurrent_scnfromv$database
CURRENT_SCN

1043322
SQL>droptablespacemyexampleincludingcontentsanddatafiles
Tablespacedropped.

RMAN>run{
2>setnewnamefordatafile7to'+DATA'
3>recovertablespacemyexample

http://gavinsoorma.com/2009/11/11grelease2tablespacepointintimerecoveryrecoverfromdroppedtablespace/

1/7

28/11/2015

11gRelease2TablespacePointInTimeRecoveryrecoverfromdroppedtablespaceOracleDBATipsandTechniques

3>recovertablespacemyexample
4>untilscn1043322
5>auxiliarydestination'+DATA'
6>}
executingcommand:SETNEWNAME
Startingrecoverat27NOV09
allocatedchannel:ORA_DISK_1
channelORA_DISK_1:SID=137devicetype=DISK
Creatingautomaticinstance,withSID='qyBo'
initializationparametersusedforautomaticinstance:
db_name=TESTDB
db_unique_name=qyBo_tspitr_TESTDB
compatible=11.2.0.0.0
db_block_size=8192
db_files=200
sga_target=280M
processes=50
db_create_file_dest=+DATA
log_archive_dest_1='location=+DATA'
#Noauxiliaryparameterfileused

startingupautomaticinstanceTESTDB
Oracleinstancestarted
TotalSystemGlobalArea292278272bytes
FixedSize2212736bytes
VariableSize100666496bytes
DatabaseBuffers184549376bytes
RedoBuffers4849664bytes
Automaticinstancecreated
contentsofMemoryScript:
{
#setrequestedpointintime
setuntilscn1043322
#restorethecontrolfile
restoreclonecontrolfile
#mountthecontrolfile
sqlclone'alterdatabasemountclonedatabase'
#archivecurrentonlinelog
sql'altersystemarchivelogcurrent'
#avoidunnecessaryautobackupsforstructuralchangesduringTSPITR
sql'begindbms_backup_restore.AutoBackupFlag(FALSE)end'
#resynccatalog
resynccatalog
}
executingMemoryScript
executingcommand:SETuntilclause
Startingrestoreat27NOV09
allocatedchannel:ORA_AUX_DISK_1
http://gavinsoorma.com/2009/11/11grelease2tablespacepointintimerecoveryrecoverfromdroppedtablespace/

2/7

28/11/2015

11gRelease2TablespacePointInTimeRecoveryrecoverfromdroppedtablespaceOracleDBATipsandTechniques

allocatedchannel:ORA_AUX_DISK_1
channelORA_AUX_DISK_1:SID=81devicetype=DISK

channelORA_AUX_DISK_1:startingdatafilebackupsetrestore
channelORA_AUX_DISK_1:restoringcontrolfile
channelORA_AUX_DISK_1:readingfrombackuppiece+DATA/testdb/backupset/2009_11_27/ncsnf0_tag2009
704025815
channelORA_AUX_DISK_1:piecehandle=+DATA/testdb/backupset/2009_11_27/ncsnf0_tag20091127t104307_0
704025815tag=TAG20091127T104307
channelORA_AUX_DISK_1:restoredbackuppiece1
channelORA_AUX_DISK_1:restorecomplete,elapsedtime:00:00:04
outputfilename=+DATA/testdb/controlfile/current.506.704033345
Finishedrestoreat27NOV09
sqlstatement:alterdatabasemountclonedatabase
sqlstatement:altersystemarchivelogcurrent
sqlstatement:begindbms_backup_restore.AutoBackupFlag(FALSE)end
startingfullresyncofrecoverycatalog
fullresynccomplete
contentsofMemoryScript:
{
#setrequestedpointintime
setuntilscn1043322
#setdestinationsforrecoverysetandauxiliarysetdatafiles
setnewnameforclonedatafile1tonew
setnewnameforclonedatafile3tonew
setnewnameforclonedatafile2tonew
setnewnameforclonetempfile1tonew
setnewnamefordatafile7to
"+DATA"
#switchalltempfiles
switchclonetempfileall
#restorethetablespacesintherecoverysetandtheauxiliaryset
restoreclonedatafile1,3,2,7
switchclonedatafileall
}
executingMemoryScript
executingcommand:SETuntilclause
executingcommand:SETNEWNAME
executingcommand:SETNEWNAME
executingcommand:SETNEWNAME
executingcommand:SETNEWNAME
executingcommand:SETNEWNAME
renamedtempfile1to+DATAincontrolfile
Startingrestoreat27NOV09
usingchannelORA_AUX_DISK_1
channelORA_AUX_DISK_1:startingdatafilebackupsetrestore
http://gavinsoorma.com/2009/11/11grelease2tablespacepointintimerecoveryrecoverfromdroppedtablespace/

3/7

28/11/2015

11gRelease2TablespacePointInTimeRecoveryrecoverfromdroppedtablespaceOracleDBATipsandTechniques

channelORA_AUX_DISK_1:startingdatafilebackupsetrestore
channelORA_AUX_DISK_1:specifyingdatafile(s)torestorefrombackupset
channelORA_AUX_DISK_1:restoringdatafile00001to+DATA
channelORA_AUX_DISK_1:restoringdatafile00003to+DATA
channelORA_AUX_DISK_1:restoringdatafile00002to+DATA
channelORA_AUX_DISK_1:restoringdatafile00007to+DATA
channelORA_AUX_DISK_1:readingfrombackuppiece+DATA/testdb/backupset/2009_11_27/nnndf0_tag2009
channelORA_AUX_DISK_1:piecehandle=+DATA/testdb/backupset/2009_11_27/nnndf0_tag20091127t104307_0
704025789tag=TAG200.........
channelORA_AUX_DISK_1:restoredbackuppiece1
channelORA_AUX_DISK_1:restorecomplete,elapsedtime:00:00:26
Finishedrestoreat27NOV09
datafile7switchedtodatafilecopy
inputdatafilecopyRECID=6STAMP=704033380filename=+DATA/testdb/datafile/myexample.512.
704033355
datafile1switchedtodatafilecopy
inputdatafilecopyRECID=7STAMP=704033380filename=+DATA/testdb/datafile/system.511.
704033355
datafile3switchedtodatafilecopy
inputdatafilecopyRECID=8STAMP=704033380filename=+DATA/testdb/datafile/undotbs1.513.
704033355
datafile2switchedtodatafilecopy
inputdatafilecopyRECID=9STAMP=704033380filename=+DATA/testdb/datafile/sysaux.509.
704033355

contentsofMemoryScript:
{
#setrequestedpointintime
setuntilscn1043322
#onlinethedatafilesrestoredorswitched
sqlclone"alterdatabasedatafile1online"
sqlclone"alterdatabasedatafile3online"
sqlclone"alterdatabasedatafile2online"
sqlclone"alterdatabasedatafile7online"
#recoverandopenresetlogs
recoverclonedatabasetablespace"MYEXAMPLE","SYSTEM","UNDOTBS1","SYSAUX"deletearchivelog
alterclonedatabaseopenresetlogs
}
executingMemoryScript
executingcommand:SETuntilclause
sqlstatement:alterdatabasedatafile1online
sqlstatement:alterdatabasedatafile3online
sqlstatement:alterdatabasedatafile2online
sqlstatement:alterdatabasedatafile7online
Startingrecoverat27NOV09
usingchannelORA_AUX_DISK_1
startingmediarecovery

archivedlogforthread1withsequence10isalreadyondiskasfile+DATA/testdb/archivelog/2009
archivedlogforthread1withsequence11isalreadyondiskasfile+DATA/testdb/archivelog/2009
archivedlogforthread1withsequence12isalreadyondiskasfile+DATA/testdb/archivelog/2009

http://gavinsoorma.com/2009/11/11grelease2tablespacepointintimerecoveryrecoverfromdroppedtablespace/

4/7

28/11/2015

11gRelease2TablespacePointInTimeRecoveryrecoverfromdroppedtablespaceOracleDBATipsandTechniques

archivedlogforthread1withsequence12isalreadyondiskasfile+DATA/testdb/archivelog/2009
archivedlogfilename=+DATA/testdb/archivelog/2009_11_27/....
archivedlogfilename=+DATA/testdb/archivelog/2009_11_27/....
archivedlogfilename=+DATA/testdb/archivelog/2009_11_27/....
mediarecoverycomplete,elapsedtime:00:00:01
Finishedrecoverat27NOV09
databaseopened
contentsofMemoryScript:
{
#makereadonlythetablespacethatwillbeexported
sqlclone'altertablespaceMYEXAMPLEreadonly'
#createdirectoryfordatapumpimport
sql"createorreplacedirectoryTSPITR_DIROBJ_DPDIRas''
+DATA''"
#createdirectoryfordatapumpexport
sqlclone"createorreplacedirectoryTSPITR_DIROBJ_DPDIRas''
+DATA''"
}
executingMemoryScript
sqlstatement:altertablespaceMYEXAMPLEreadonly
sqlstatement:createorreplacedirectoryTSPITR_DIROBJ_DPDIRas''+DATA''
sqlstatement:createorreplacedirectoryTSPITR_DIROBJ_DPDIRas''+DATA''
Performingexportofmetadata...
EXPDP>Starting"SYS"."TSPITR_EXP_qyBo":
EXPDP>ProcessingobjecttypeTRANSPORTABLE_EXPORT/PLUGTS_BLK
EXPDP>ProcessingobjecttypeTRANSPORTABLE_EXPORT/TABLE
EXPDP>ProcessingobjecttypeTRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
EXPDP>Mastertable"SYS"."TSPITR_EXP_qyBo"successfullyloaded/unloaded
EXPDP>******************************************************************************
EXPDP>DumpfilesetforSYS.TSPITR_EXP_qyBois:
EXPDP>+DATA/tspitr_qybo_53647.dmp
EXPDP>******************************************************************************
EXPDP>DatafilesrequiredfortransportabletablespaceMYEXAMPLE:
EXPDP>+DATA/testdb/datafile/myexample.512.704033355
EXPDP>Job"SYS"."TSPITR_EXP_qyBo"successfullycompletedat12:51:34
Exportcompleted

contentsofMemoryScript:
{
#shutdownclonebeforeimport
shutdowncloneimmediate
}
executingMemoryScript
databaseclosed
databasedismounted
Oracleinstanceshutdown
Performingimportofmetadata...
IMPDP>Mastertable"SYS"."TSPITR_IMP_qyBo"successfullyloaded/unloaded
IMPDP>Starting"SYS"."TSPITR_IMP_qyBo":
http://gavinsoorma.com/2009/11/11grelease2tablespacepointintimerecoveryrecoverfromdroppedtablespace/

5/7

28/11/2015

11gRelease2TablespacePointInTimeRecoveryrecoverfromdroppedtablespaceOracleDBATipsandTechniques

IMPDP>Starting"SYS"."TSPITR_IMP_qyBo":
IMPDP>ProcessingobjecttypeTRANSPORTABLE_EXPORT/PLUGTS_BLK
IMPDP>ProcessingobjecttypeTRANSPORTABLE_EXPORT/TABLE
IMPDP>ProcessingobjecttypeTRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
IMPDP>Job"SYS"."TSPITR_IMP_qyBo"successfullycompletedat12:51:49
Importcompleted

contentsofMemoryScript:
{
#makereadwriteandofflinetheimportedtablespaces
sql'altertablespaceMYEXAMPLEreadwrite'
sql'altertablespaceMYEXAMPLEoffline'
#enableautobackupsafterTSPITRisfinished
sql'begindbms_backup_restore.AutoBackupFlag(TRUE)end'
#resynccatalog
resynccatalog
}
executingMemoryScript
sqlstatement:altertablespaceMYEXAMPLEreadwrite
sqlstatement:altertablespaceMYEXAMPLEoffline
sqlstatement:begindbms_backup_restore.AutoBackupFlag(TRUE)end
startingfullresyncofrecoverycatalog
fullresynccomplete
Removingautomaticinstance
Automaticinstanceremoved
auxiliaryinstancefile+DATA/testdb/tempfile/temp.518.704033385deleted
auxiliaryinstancefile+DATA/testdb/onlinelog/group_3.517.704033385deleted
auxiliaryinstancefile+DATA/testdb/onlinelog/group_2.515.704033383deleted
auxiliaryinstancefile+DATA/testdb/onlinelog/group_1.514.704033383deleted
auxiliaryinstancefile+DATA/testdb/datafile/sysaux.509.704033355deleted
auxiliaryinstancefile+DATA/testdb/datafile/undotbs1.513.704033355deleted
auxiliaryinstancefile+DATA/testdb/datafile/system.511.704033355deleted
auxiliaryinstancefile+DATA/testdb/controlfile/current.506.704033345deleted
Finishedrecoverat27NOV09
RMAN>

Note:Aftertherecoveryiscomplete,weneedtobringthetablespaceanddatafileonlineaswell.
SQL>altertablespacemyexampleonline
Tablespacealtered.
SQL>alterdatabasedatafile'+DATA/testdb/datafile/myexample.512.704033355'online
Databasealtered.
SQL>selectfile_namefromdba_data_fileswheretablespace_name='MYEXAMPLE'
FILE_NAME

+DATA/testdb/datafile/myexample.512.704033355

http://gavinsoorma.com/2009/11/11grelease2tablespacepointintimerecoveryrecoverfromdroppedtablespace/

6/7

28/11/2015

11gRelease2TablespacePointInTimeRecoveryrecoverfromdroppedtablespaceOracleDBATipsandTechniques

+DATA/testdb/datafile/myexample.512.704033355
SQL>selecttable_namefromdba_tables
2wheretablespace_name='MYEXAMPLE'
TABLE_NAME

MYSALES
MYCOSTS
SQL>selectcount(*)fromsh.mysales
COUNT(*)

918843

November27th,2009|Tags:11gR2,auxiliaryinstance,droptablespace,tablespacepointintimerecovery,tspitr|Category:
BackupandRecovery,Oracle11grelease2

http://gavinsoorma.com/2009/11/11grelease2tablespacepointintimerecoveryrecoverfromdroppedtablespace/

7/7

Das könnte Ihnen auch gefallen