如何使用 RMAN 異機恢複部分資料表空間,rman空間
在oracle 資料庫的日常維護和使用期間難免會遇到誤刪資料(drop,delete, truncate)當我們使用常規手段(flashback query ,flashback drop)也無法恢複資料時,我們可以使用最近的邏輯備份,在異機使用dmp 來恢複相應的表,但是如果沒有這些邏輯備份,但是有一個最近的rman 全備,那麼我們就可以利用這個備份來恢複被誤刪的資料表空間,從而實現資料的恢複,這裡我以NBU 的備份環境為例簡單描述下如何來回複部分 資料表空間;
-------在nomount 狀態 ,恢複控制檔案
run {
allocate channel t1 type 'sbt_tape';
send 'NB_ORA_SERV=netbackup,NB_ORA_CLIENT=http://blog.csdn.net/lixora';
restore controlfile to '/oracle11/oradata1/control011.ctl' from '/c-2151157071-20141111-00';
release channel t1 ;
}
-------在還原好控制檔案後,將執行個體啟動到mount狀態,然後開始還原部分資料表空間資料檔案:
rman target / nocatalog msglog=/home/oracledb/rman.log <<EOF
run {
allocate channel t1 type 'sbt_tape';
allocate channel t2 type 'sbt_tape';
send 'NB_ORA_SERV=netbackup,NB_ORA_CLIENT=http://blog.csdn.net/lixora';
set newname for datafile 1 to '/oracle11/oradata/datafile/system.262.762381347' ;
set newname for datafile 3 to '/oracle11/oradata/datafile/undotbs1.264.762381401';
set newname for datafile 4 to '/oracle11/oradata/datafile/undotbs2.266.762381455';
set newname for datafile 227 to '/oracle11/oradata/datafile/system02.dbf';
set newname for datafile 344 to '/oracle11/oradata/datafile/lixora.375.820259689';
set newname for datafile 345 to '/oracle11/oradata/datafile/lixora.414.820949317';
restore tablespace system,undotbs1,undotbs2,lixora ;
switch datafile all;
release channel t1;
release channel t2;
}
EOF
---------【如果表空比較多,可以先批量產生資料表空間的 offline drop 命令】開始恢複資料庫
rman target / msglog=recover.log << EOF
RUN{
ALLOCATE CHANNEL ch0 TYPE 'SBT_TAPE' ;
ALLOCATE CHANNEL ch1 TYPE 'SBT_TAPE' ;
send 'NB_ORA_SERV=netbackup,NB_ORA_CLIENT=http://blog.csdn.net/lixora';
set until time "to_date('2014/11/11 14:00:00','yyyy/mm/dd hh24:mi:ss')";
recover database skip forever tablespace SYSAUX,TEMP,USERS,INDEX_DATA;
release channel ch0;
release channel ch1;
}
EOF
---以resetlogs 方式開啟oracle資料庫
alter database open resetlogs;