在不同情况下使用RMAN对ORACLE数据库进行恢复.docx
《在不同情况下使用RMAN对ORACLE数据库进行恢复.docx》由会员分享,可在线阅读,更多相关《在不同情况下使用RMAN对ORACLE数据库进行恢复.docx(13页珍藏版)》请在冰豆网上搜索。
![在不同情况下使用RMAN对ORACLE数据库进行恢复.docx](https://file1.bdocx.com/fileroot1/2023-1/21/79292772-132c-43dc-8fc5-ce6bb634e3bb/79292772-132c-43dc-8fc5-ce6bb634e3bb1.gif)
在不同情况下使用RMAN对ORACLE数据库进行恢复
1.全数据库的完全恢复
run
{allocatechannelc11typedisk;
allocatechannelc12typedisk;
allocatechannelc21type'sbt_tape';
allocatechannelc22type'sbt_tape';
restorecontrolfile;
alterdatabasemount;
restoredatabase;
recoverdatabase;
sql"alterdatabaseopen";
releasechannelc11;
releasechannelc12;
releasechannelc21;
releasechannelc22;
}
恢复步骤如下:
$svrmgrl
svrmgr>connectinternal
svrmgr>startupnomount
$rmanprodrecdbs.rcv>>rec.log&
$tail–frec.log #观察日志
使用以上以上的全备份可以对数据库进行全库的恢复,并可以在恢复脚本中直接实现数据库归档日志的应用,将数据库自动恢复到最近的日志记录的状态。
注意:
恢复时如果有需要应用很多归档日志,则应用该日志时时间会比较长,一定要耐心等待。
全恢复日志如下:
RecoveryManager:
Release8.0.5.2.1-Production
RMAN-00569:
================errormessagestackfollows================
RMAN-00554:
initializationofinternalrecoverymanagerpackagefailed
RMAN-04005:
errorfromtargetdatabase:
ORA-01034:
ORACLEnotavailable
RecoveryManager:
Release8.0.5.2.1-Production
RMAN-06005:
connectedtotargetdatabase:
FJTEST
RMAN-06008:
connectedtorecoverycatalogdatabase
RMAN>run
2>{
3> allocatechannelc11typedisk;
4> allocatechannelc12typedisk;
5> allocatechannelc21type'sbt_tape';
6> allocatechannelc22type'sbt_tape';
7> restoredatabase;
8> recoverdatabase;
9> sql"alterdatabaseopen";
10> releasechannelc11;
11> releasechannelc12;
12> releasechannelc21;
13> releasechannelc22;
14>}
15>
RMAN-03022:
compilingcommand:
allocate
RMAN-03023:
executingcommand:
allocate
RMAN-08030:
allocatedchannel:
c11
RMAN-08500:
channelc11:
sid=13devtype=DISK
RMAN-03022:
compilingcommand:
allocate
RMAN-03023:
executingcommand:
allocate
RMAN-08030:
allocatedchannel:
c12
RMAN-08500:
channelc12:
sid=14devtype=DISK
RMAN-03022:
compilingcommand:
allocate
RMAN-03023:
executingcommand:
allocate
RMAN-08030:
allocatedchannel:
c21
RMAN-08500:
channelc21:
sid=15devtype=SBT_TAPE
RMAN-03022:
compilingcommand:
allocate
RMAN-03023:
executingcommand:
allocate
RMAN-08030:
allocatedchannel:
c22
RMAN-08500:
channelc22:
sid=17devtype=SBT_TAPE
RMAN-03022:
compilingcommand:
set
RMAN-03022:
compilingcommand:
restore
RMAN-03025:
performingimplicitpartialresyncofrecoverycatalog
RMAN-03023:
executingcommand:
partialresync
RMAN-08003:
startingpartialresyncofrecoverycatalog
RMAN-08005:
partialresynccomplete
RMAN-03022:
compilingcommand:
IRESTORE
RMAN-03023:
executingcommand:
IRESTORE
RMAN-08016:
channelc21:
startingdatafilebackupsetrestore
RMAN-08502:
set_count=28set_stamp=402253457
RMAN-08016:
channelc22:
startingdatafilebackupsetrestore
RMAN-08502:
set_count=29set_stamp=402253577
RMAN-08019:
channelc21:
restoringdatafile1
RMAN-08509:
destinationforrestoreofdatafile1:
/dev/vx/rdsk/datadg/system01
RMAN-08019:
channelc22:
restoringdatafile3
RMAN-08509:
destinationforrestoreofdatafile3:
/dev/vx/rdsk/datadg/tempa
RMAN-08019:
channelc21:
restoringdatafile2
RMAN-08509:
destinationforrestoreofdatafile2:
/dev/vx/rdsk/datadg/rbsa
RMAN-08019:
channelc22:
restoringdatafile16
RMAN-08509:
destinationforrestoreofdatafile16:
/dev/vx/rdsk/datadg/t3s200n1
RMAN-08023:
channelc21:
restoredbackuppiece1
RMAN-08511:
piecehandle=dbf_28_402253457_1params=NULL
RMAN-08024:
channelc21:
restorecomplete
RMAN-08016:
channelc21:
startingdatafilebackupsetrestore
RMAN-08502:
set_count=31set_stamp=402253614
RMAN-08019:
channelc21:
restoringdatafile4
RMAN-08509:
destinationforrestoreofdatafile4:
/dev/vx/rdsk/datadg/tools
RMAN-08019:
channelc21:
restoringdatafile7
RMAN-08509:
destinationforrestoreofdatafile7:
/dev/vx/rdsk/datadg/tempb
RMAN-08023:
channelc22:
restoredbackuppiece1
RMAN-08511:
piecehandle=dbf_29_402253577_1params=NULL
RMAN-08024:
channelc22:
restorecomplete
RMAN-08016:
channelc22:
startingdatafilebackupsetrestore
RMAN-08502:
set_count=32set_stamp=402253679
RMAN-08019:
channelc22:
restoringdatafile5
RMAN-08509:
destinationforrestoreofdatafile5:
/dev/vx/rdsk/datadg/users
RMAN-08019:
channelc22:
restoringdatafile13
RMAN-08509:
destinationforrestoreofdatafile13:
/dev/vx/rdsk/datadg/t3s1n1
RMAN-08023:
channelc21:
restoredbackuppiece1
RMAN-08511:
piecehandle=dbf_31_402253614_1params=NULL
RMAN-08024:
channelc21:
restorecomplete
RMAN-08016:
channelc21:
startingdatafilebackupsetrestore
RMAN-08502:
set_count=30set_stamp=402253614
RMAN-08019:
channelc21:
restoringdatafile6
RMAN-08509:
destinationforrestoreofdatafile6:
/dev/vx/rdsk/datadg/rbsb
RMAN-08019:
channelc21:
restoringdatafile17
RMAN-08509:
destinationforrestoreofdatafile17:
/dev/vx/rdsk/datadg/t2s200n8
RMAN-08023:
channelc21:
restoredbackuppiece1
RMAN-08511:
piecehandle=dbf_30_402253614_1params=NULL
RMAN-08024:
channelc21:
restorecomplete
RMAN-08016:
channelc21:
startingdatafilebackupsetrestore
RMAN-08502:
set_count=26set_stamp=402253457
RMAN-08019:
channelc21:
restoringdatafile8
RMAN-08509:
destinationforrestoreofdatafile8:
/dev/vx/rdsk/datadg/system02
RMAN-08019:
channelc21:
restoringdatafile10
RMAN-08509:
destinationforrestoreofdatafile10:
/dev/vx/rdsk/datadg/t3s500n2
RMAN-08023:
channelc22:
restoredbackuppiece1
RMAN-08511:
piecehandle=dbf_32_402253679_1params=NULL
RMAN-08024:
channelc22:
restorecomplete
RMAN-08016:
channelc22:
startingdatafilebackupsetrestore
RMAN-08502:
set_count=25set_stamp=402253457
RMAN-08023:
channelc21:
restoredbackuppiece1
RMAN-08511:
piecehandle=dbf_26_402253457_1params=NULL
RMAN-08024:
channelc21:
restorecomplete
RMAN-08016:
channelc21:
startingdatafilebackupsetrestore
RMAN-08502:
set_count=27set_stamp=402253457
RMAN-08019:
channelc22:
restoringdatafile9
RMAN-08509:
destinationforrestoreofdatafile9:
/dev/vx/rdsk/datadg/t2s500n2
RMAN-08019:
channelc21:
restoringdatafile11
RMAN-08509:
destinationforrestoreofdatafile11:
/dev/vx/rdsk/datadg/t2s500n10
RMAN-08019:
channelc22:
restoringdatafile12
RMAN-08509:
destinationforrestoreofdatafile12:
/dev/vx/rdsk/datadg/t3s500n1
RMAN-08019:
channelc21:
restoringdatafile14
RMAN-08509:
destinationforrestoreofdatafile14:
/dev/vx/rdsk/datadg/t2s200n10
RMAN-08023:
channelc22:
restoredbackuppiece1
RMAN-08511:
piecehandle=dbf_25_402253457_1params=NULL
RMAN-08024:
channelc22:
restorecomplete
RMAN-08016:
channelc22:
startingdatafilebackupsetrestore
RMAN-08502:
set_count=33set_stamp=402253726
RMAN-08019:
channelc22:
restoringdatafile15
RMAN-08509:
destinationforrestoreofdatafile15:
/dev/vx/rdsk/datadg/t2s1n1
RMAN-08023:
channelc21:
restoredbackuppiece1
RMAN-08511:
piecehandle=dbf_27_402253457_1params=NULL
RMAN-08024:
channelc21:
restorecomplete
RMAN-08023:
channelc22:
restoredbackuppiece1
RMAN-08511:
piecehandle=dbf_33_402253726_1params=NULL
RMAN-08024:
channelc22:
restorecomplete
RMAN-03023:
executingcommand:
partialresync
RMAN-08003:
startingpartialresyncofrecoverycatalog
RMAN-08005:
partialresynccomplete
RMAN-03022:
compilingcommand:
recover
RMAN-03022:
compilingcommand:
recover
(1)
RMAN-03022:
compilingcommand:
recover
(2)
RMAN-03022:
compilingcommand:
recover(3)
RMAN-03023:
executingcommand:
recover(3)
RMAN-08054:
startingmediarecovery
RMAN-08515:
archivelogfilename=/archlog/arch2_1.logthread=2sequence=1
RMAN-08515:
archivelogfilename=/archlog/arch1_1.logthread=1sequence=1
RMAN-08515:
archivelogfilename=/archlog/arch2_2.logthread=2sequence=2
RMAN-08515:
archivelogfilename=/archlog/arch2_3.logthread=2sequence=3
RMAN-08515:
archivelogfilename=/archlog/arch2_4.logthread=2sequence=4
RMAN-08515:
archivelogfilename=/archlog/arch1_2.logthread=1sequence=2
RMAN-08515:
archivelogfilename=/archlog/arch2_5.logthread=2sequence=5
RMAN-08515:
archivelogfilename=/archlog/arch2_6.logthread=2sequence=6
RMAN-08515:
archivelogfilename=/archlog/arch1_3.logthread=1sequence=3
RMAN-08515:
archivelogfilename=/archlog/arch2_7.logthread=2sequence=7
RMAN-08515:
archivelogfilename=/archlog/arch2_8.logthread=2sequence=8
RMAN-08515:
archivelogfilename=/archlog/arch2_9.logthread=2sequence=9
RMAN-08055:
mediarecoverycomplete
RMAN-03022:
compilingcommand:
recover(4)
RMAN-03022:
compilingcommand:
sql
RMAN-06162:
sqlstatement:
alterdatabaseopen
RMAN-03023:
executingcommand:
sql
RMAN-03026:
errorrecoveryreleasingchannelresources
RMAN-08031:
releasedchannel:
c12
RMAN-08031:
releasedchannel:
c11
RMAN-08031:
releasedchannel:
c21
RMAN-08031:
releasedchannel:
c22
RecoveryManagercomplete.
以下将不注明恢复日志。
2.表空间的恢复
run
{allocatechannelc11typedisk;
allocatechannelc12typedisk;
allocatechannelc21type'sbt_tape';
allocatechannelc22type'sbt_tape';
sql"altertablespacetest_tbs1offlineimmediate"; #使表空间离线
restoretablespacetest_tbs1; #物理恢复表空间
recovertablespacetest_tbs1; #逻辑恢复表空间(应用日志)
sql"altertablespacetest_tbs1online"; #使表空间在线
releasechannelc11;
releasechannelc12;
releasechannelc21;
releasechannelc22;
}
表空间恢复分为离线和在线两种,数据库在线时,如果某表空间发生损坏,可以进行在线的表空间恢复,该任务不会影响数据库其他表空间的正常运行。
当系统表空间损坏,导致数据库不能正常运行,因此需离线恢复系统表空间。
测试步骤如下:
在线恢复某应用表空间
a) 破坏某表空间数据文件
$cd/dev/vx/rdsk/datadg
$ddif=data01of=data02bs=10k
b) 对该数据文件进行操作
svrmgr>altersystemcheckdatafiles;
svrmgr>selectfile#,status,errorfromv$datafile_header
如果发现错误,则该数据库文件已经被损坏。
c) 恢复该表空间
svrmgr>altertablespacetest_tbs1offline;
$rmanprodrectbs.rcv>>rec2.log&
svrmgr>selectfile#,status,errorfromv$datafile_header
在使用上命令查看恢复情况,如果所有的数据文件状态都为“online”,即表明本恢复成功。
3.系统表空间的恢复(数据文