RMAN恢复指定的表空间

Posted by wukaiqiang; tagged with oracle

一、使用场景

在expdp备份不能满足要求的情况下,需要通过rman恢复单表数据,针对表空间恢复是一种比较合理的方式。

二、操作步骤

查询表空间信息

SQL> select distinct b.name from v$tablespace b;

复制表空间

SQL>
run {
allocate channel ch00 type sbt_tape;
allocate channel ch01 type sbt_tape;
send 'NB_ORA_SERV=hz-ps-bak01,NB_ORA_CLIENT=hwdb01';
set newname for datafile '+DATA/bydmes/datafile/system.260.1109607975' to '/u01/app/oradata/system.260.1109607975';
set newname for datafile '+DATA/bydmes/datafile/sysaux.261.1109607985' to '/u01/app/oradata/sysaux.261.1109607985';
restore tablespace SYSAUX,SYSTEM,UNDOTBS1,UNDOTBS2,USERS,YBWMS_KC;
switch datafile all;
release channel ch00;
release channel ch01;
}

注册归档日志

catalog start with '/opt/archbak20230114';

恢复表空间到指定时间点

run{
sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"';
set until time '2023-01-14 09:30:00';
allocate channel ch00 type sbt_tape;
allocate channel ch01 type sbt_tape;
allocate channel ch02 type sbt_tape;
send 'NB_ORA_SERV=hz-ps-bak01,NB_ORA_CLIENT=hwdb01';
recover tablespace SYSAUX,SYSTEM,UNDOTBS1,UNDOTBS2,USERS,YBWMS_KC;;
switch datafile all;
release channel ch00;
release channel ch01;
release channel ch02;
}

打开数据库

SQL>alter database open resetlogs

备注:
问题处理过程中遇到了一下问题:

**1、使用restore指定数据文件方式恢复,导致undo表空间的数据文件恢复少了,把缺少的数据文件补充上即可。
2、spfile中sga和pga大小指定太小,导致数据库应用太慢,可以ctrl+c停止后,修改完参数再执行,同时操作系统中的sysctl.conf配置过低,也需要修改。**