rman高級恢復主題

rman 的高級恢復主題
使用resetlogs,在不完全恢復期間,通常需要使用resetlogs命令打開數據庫,這是因爲我們要從已經建立的現有重做流中脫離出來。並且向oracle說明這個情況。
resetlogs 命令表示一個數據庫邏輯生存期的結束和另一個數據庫邏輯生存期的開始。數據庫的邏輯生存期間也稱爲一個對應物。
創建恢復點
基於時間的恢復
 tartup mount;
 restore database until time "to_date('06/28/06 13:00:00','MM/DD/YYYY HH24:MI:SS')";
 recover database until time "to_date('06/28/06 13:00:00','MM/DD/YYYY HH24:MI:SS')";
 alter database open resetlogs;
基於scn的恢復
 startup mount;
 restore database until scn 10000;
 recover database until scn 10000;
 alter database open resetlogs;
基於日誌序列的恢復
 startup mount;
 restore database until sequence 100 thread 1;
 recover database until sequence 100 thread 1;
 alter database open resetlogs;
基於刪除的恢復
使用還原點恢復
 startup mount;
 restore database until  restore point tango_one;
 recover database until  restore point tango_one;
 alter database open resetlogs;

只讀表空間的恢復
   restore database check readonly;(默認情況下,丟失了只讀數據文件,執行完全數據庫還原也不會還原只讀數據文件,必須在命令中使用check readonly纔可以還原只讀數據文件)
歸檔重做日誌還原
   restore archivelog all;
   restore archivelog from logseq=20 thread=1;
   restore archivelog from logseq=20 until logseq=30 thread=1;
數據文件副本還原(從數據庫副本而不是備份集中還原數據庫數據文件)
   restore (datafile 5) from datafilecopy;這條命令會識別需要還原的數據文件的最新副本,然後從這個副本中還原這些數據文件,數據文件的最新副本可能在一個數據文件副本中,而不是在備份集中。
   recover datafile 5;
   sql "alter database datafile 5 online";
恢復損壞的數據塊
    blockrecover datafile 10 block 44,55,99
恢復前一個對應物    
I使用恢復目錄恢復前一個對應物
    startup forces nomount
    reset database to incarnation 2;
    restore controlfile;
    restore database until scn 7623545;
    recover database until scn 7623545;
    alter database open resetlogs;
II不使用恢復目錄恢復前一個對應物
    shutdown immediate;
    startup mount
    reset database to incarnation 2;
    restore database until scn 7623545;
    recover database until scn 7623545;
    alter database open resetlogs;
表空間時間點恢復
   確保還原的時間點
   確保對象完全包含在希望還原的表空間中
   確保可能丟失的對象或數據
    
驗證備份可恢復
  restore database preview;
  restore database validate;
 
跨平臺的數據庫移動和rman

   尾數格式與字節排序有關,它有兩種不同的格式,大尾數和小尾數。要在不同尾數字節格式的平臺之間移動數據,則需要手動操作,並且使用rman的convert datafile或convert tablespace命令將傳送的數據文件轉換爲正確的尾數格式。
   只有在設置爲可讀寫或聯機時,只讀文件和脫機數據文件纔可支持跨平臺操作。
  如果字節排序方案不同,則需要在rman中使用convert命令將表空間轉換爲目標平臺所需的格式。
  select endian_format from v$transportable_platform tp ,v$database d where tp.platform_name=d.platform_name;

  select platform_name from v$transportable_platform;

  使用rman轉換表空間尾數格式
將表空間設置爲只讀模式,啓動rman並使用新的convert tablespace命令
rman> convert tablespace users to platform='AIX-Based Systems (64-bit)'
db_file_name_convert='c:\oracle\oradata\betatwo','c:\oracle\admin\transport_aix'
 也可以轉換目標站點上的數據文件
rman> convert datafile ='c:\oracle\oradata\betatwo\*' platform='AIX-Based Systems (64-bit)'
db_file_name_convert='c:\oracle\oradata\betatwo','c:\oracle\admin\transport_aix'

 跨平臺移動數據:;
(1) startup mount;
     alter database open read only;
(2)使用dbms_tdb.check_db進程來檢查數據庫狀態
   set serveroutput on
   declare
 db_ready boolean;
begin
 db_ready:=dbms_tdb.check_db
 ('Microsoft Windows IA (32-bit)',dbms_tdb.skip_Readonly);
end;
/
(3)使用dbms_tdb.check_external進程來標識外部對象
set serveroutput on
declare
 extrnal boolean
 begin
 external:=dbms_tdb.check_external;
end;
/
(4)當數據庫可以傳送時,就可以使用rman的convert database命令。rman創建數據庫移動所需的腳本,但不真正移動操作。而是創建移動所需的文件。
convert database new database 'copydb' transport script 'c:\oracle\copydb\copysripts' to platform 'Microsoft Windows IA (32-bit)'
可選參數db_file_name_convert 允許用戶爲需要轉換的數據文件定義目錄文件名。
convert database new database 'copydb' transport script 'c:\oracle\copydb\copysripts' to platform 'Microsoft Windows IA (32-bit)'
db_file_name_convert  'c:\oracle\product\10.2.0\oradata\rob10r2','c:\oracle\newdbdest'
發佈了51 篇原創文章 · 獲贊 3 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章