在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=';
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=';
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;
--------------------------------------推荐阅读 --------------------------------------
--------------------------------------分割线 --------------------------------------