您好,登錄后才能下訂單哦!
一般如下:系統崩潰,rman使用控制文件,沒有使用控制文件自動備份,現在僅有最后一次全備(備份中包括控制文件),以及其增量備份,規檔備份.
通常這種情況下不能使用常規RMAN來恢復,因為此全備份中備份的控制文件中沒有包含本次的備份信息,rman使用控制文件備份的時候是先備份控制文件
后備份其它信息
背景知識
在Oracle 816 以后的版本中,Oracle提供了一個包:DBMS_BACKUP_RESTORE.DBMS_BACKUP_RESTORE 包是由dbmsbkrs.sql 和 prvtbkrs.plb 這兩個腳本創建的.catproc.sql 腳本運行后會調用這兩個包.所以是每個數據庫都有的這個包是Oracle服務器和操作系統之間IO操作的接口.由恢復管理器直接調用。而且據說這兩個腳本的功能是內建到Oracle的一些庫文件中的.
由此可見,我們可以在數據庫 nomount 情況下調用這些package ,來達到我們的恢復目的。在dbmsbkrs.sql 和prvtbkrs.plb 這兩個腳本中有詳細的說明文檔
關鍵的內容有:
FUNCTION deviceAllocate(
type IN varchar2 default NULL
,name IN varchar2 default NULL
,ident IN varchar2 default NULL
,noio IN boolean default FALSE
,params IN varchar2 default NULL )
RETURN varchar2;
PROCEDURE restoreControlfileTo(cfname IN varchar2);
PROCEDURE restoreDataFileTo( dfnumber IN binary_integer
,toname IN varchar2 default NULL);
SQL>startup force nomount;
SQL>
DECLARE
devtype varchar2(256);
done boolean;
BEGIN
--分配一個device channel,如果使用的操作系統文件,type就為空,如果是從磁帶上恢復要用 "sbt_tape";
devtype:=sys.dbms_backup_restore.deviceAllocate(type=>'',ident=>'t1');
--指明開始restore
sys.dbms_backup_restore.restoreSetDatafile;
--指出待恢復文件目標存儲位置;
sys.dbms_backup_restore.restoreControlfileTo(cfname=>'D:ORACLEORADATAFENETCONTROL01.CTL');
--sys.dbms_backup_restore.restoreControlfileTo(cfname=>'D:ORACLEORADATAFENETCONTROL02.CTL');
--sys.dbms_backup_restore.restoreControlfileTo(cfname=>'D:ORACLEORADATAFENETCONTROL03.CTL');
--指定備份集的位置
sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'D:ORA9I6095222264.RMAN', params=>null);
--釋放通道
sys.dbms_backup_restore.deviceDeallocate;
END;
可以通過該語句得到file#和name的對應關系
select 'sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>' || file# ||
',toname=>' ||chr(39)|| name ||chr(39) || ');',
'sys.dbms_backup_restore.applySetDatafile(dfnumber=>' || file# ||
',toname=>' ||chr(39)|| name ||chr(39) || ');'
from v$datafile;
在nomount狀態下執行以下語句
恢復0級備份的語句
DECLARE
devtype varchar2(256);
done boolean;
BEGIN
devtype:=sys.dbms_backup_restore.deviceAllocate (type=>'',ident=>'t1');
sys.dbms_backup_restore.restoreSetDatafile;
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>1,toname=>'D:ORACLEORADATAFENETSYSTEM01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>2,toname=>'D:ORACLEORADATAFENETUNDOTBS01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>3,toname=>'D:ORACLEORADATAFENETCWMLITE01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>4,toname=>'D:ORACLEORADATAFENETDRSYS01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>5,toname=>'D:ORACLEORADATAFENETEXAMPLE01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>6,toname=>'D:ORACLEORADATAFENETINDX01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>7,toname=>'D:ORACLEORADATAFENETODM01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>8,toname=>'D:ORACLEORADATAFENETTOOLS01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>9,toname=>'D:ORACLEORADATAFENETUSERS01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>10,toname=>'D:ORACLEORADATAFENETXDB01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>11,toname=>'D:ORACLEORADATAFENETBJIC.ORA');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>12,toname=>'D:ORACLEORADATAFENETPM_USERS.DBF');
sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'D:ORA9I6095222264.RMAN', params=>null);
sys.dbms_backup_restore.deviceDeallocate;
END;
恢復增量備份的語句
DECLARE
devtype varchar2(256);
done boolean;
BEGIN
devtype:=sys.dbms_backup_restore.deviceAllocate (type=>'',ident=>'t1');
sys.dbms_backup_restore.applySetDatafile;
sys.dbms_backup_restore.applySetDatafile(dfnumber=>1,toname=>'D:ORACLEORADATAFENETSYSTEM01.DBF');
sys.dbms_backup_restore.applySetDatafile(dfnumber=>2,toname=>'D:ORACLEORADATAFENETUNDOTBS01.DBF');
sys.dbms_backup_restore.applySetDatafile(dfnumber=>3,toname=>'D:ORACLEORADATAFENETCWMLITE01.DBF');
sys.dbms_backup_restore.applySetDatafile(dfnumber=>4,toname=>'D:ORACLEORADATAFENETDRSYS01.DBF');
sys.dbms_backup_restore.applySetDatafile(dfnumber=>5,toname=>'D:ORACLEORADATAFENETEXAMPLE01.DBF');
sys.dbms_backup_restore.applySetDatafile(dfnumber=>6,toname=>'D:ORACLEORADATAFENETINDX01.DBF');
sys.dbms_backup_restore.applySetDatafile(dfnumber=>7,toname=>'D:ORACLEORADATAFENETODM01.DBF');
sys.dbms_backup_restore.applySetDatafile(dfnumber=>8,toname=>'D:ORACLEORADATAFENETTOOLS01.DBF');
sys.dbms_backup_restore.applySetDatafile(dfnumber=>9,toname=>'D:ORACLEORADATAFENETUSERS01.DBF');
sys.dbms_backup_restore.applySetDatafile(dfnumber=>10,toname=>'D:ORACLEORADATAFENETXDB01.DBF');
sys.dbms_backup_restore.applySetDatafile(dfnumber=>11,toname=>'D:ORACLEORADATAFENETBJIC.ORA');
sys.dbms_backup_restore.applySetDatafile(dfnumber=>12,toname=>'D:ORACLEORADATAFENETPM_USERS.DBF');
sys.dbms_backup_restore.applyBackupPiece(done=>done,handle=>'D:ORA9I6095222264.L1', params=>null);
sys.dbms_backup_restore.deviceDeallocate
END;
恢復歸檔日志archive log文件
SQL>DECLARE
devtype varchar2(256);
done boolean;
BEGIN
devtype:=sys.dbms_backup_restore.deviceAllocate(type=>'',ident=>'T1');
sys.dbms_backup_restore.restoreSetArchivedLog;
sys.dbms_backup_restore.restoreArchivedLogRange;
sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'D:ORA9I6095222264.arc',params=>null);
sys.dbms_backup_restore.deviceDeallocate;
END
mount數據庫
SQL> alter database mount;
恢復數據庫到某一時間點
SQL> >recover database until time '2006-12-14 10:00:00';
啟動數據庫
SQL> alter database open resetlogs;
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。