Oracle 基于表空间的时间点恢复(TSPITR)

说明:本文为Oracle 11gR2基于表空间的时间点恢复(TSPITR)指导手册
标签:表空间恢复、数据恢复、不完全恢复、tablespace point in time recover
温馨提示:如果您发现本文哪里写的有问题或者有更好的写法请留言或私信我进行修改优化

正文开始


【大纲】

--环境信息
--TSPITR原理
--实验步骤
--准备环境
--创建并注册测试数据库到catalog数据库
--模拟TSPITR
--验证
--清理环境
--相关日志(中文版)
--相关日志(英文版)


★ 环境信息

/////////////////////////////////////////////////////////
测试数据库版本:11.2.0.3.0  单实例
catalog数据库版本:11.2.0.4.0  单实例
测试数据库系统版本:Centos 6.4  IP:1.1.1.9  
catalog数据库系统版本:Windows 7  IP:1.1.1.99


★ TSPITR原理

/////////////////////////////////////////////////////////
TSPITR(基于表空间的时间点恢复)其实是利用Rman的auxiliary功能创建了一个临时数据库,然后将相关表空间恢复到指定时间点,然后使用EXPDP和IMPDP功能将相关表空间中的数据从临时数据库恢复到当前数据库中以实现数据恢复


★ 实验步骤

/////////////////////////////////////////////////////////
TIME:SCN0  SCN1   SCN2
DATA:0>>>>>>1>>>>>>2
TBSA:0>>>>>>1
TBSB:0>>>>>>1>>>>>>2

  1. 实验对象:表1:A.T(表空间A),表2:B.T(表空间B)
  2. 在两个表中插入0、1、2(3条number类型的数据),并且每次插入后都记录SCN值
  3. 我们将使用RMAN的TSPITR功能只让表1(A.T)恢复到SCN2之前的状态(即SCN1)此时表1只有2条数据“0”和“1”
  4. 恢复后分别查看2个表中的数据进行对比,验证表2(B.T)没有受影响,还是SCN2时的3条数据


★ 准备环境

/////////////////////////////////////////////////////////

su - oracle
mkdir -p /home/oracle/datafile
mkdir -p /home/oracle/aux

SQL> create tablespace a datafile '/home/oracle/datafile/a.dbf' size 5M;
SQL> create user a identified by a default tablespace a;
SQL> grant dba to a;
SQL> create table a.t(id number);
SQL> create tablespace b datafile '/home/oracle/datafile/b.dbf' size 5M;
SQL> create user b identified by b default tablespace b;
SQL> grant dba to b;
SQL> create table b.t(id number);

RMAN> backup incremental level 0 database;

SQL> truncate table a.t;
SQL> truncate table b.t;
SQL> insert into a.t values(0);
SQL> commit;
SQL> insert into b.t values(0);
SQL> commit;
SQL> select current_scn from v$database;        【假设此时SCN0为:1141226】
SQL> insert into a.t values(1);
SQL> commit;
SQL> insert into b.t values(1);
SQL> commit;
SQL> select current_scn from v$database;        【假设此时SCN1为:1141231】
SQL> insert into a.t values(2);
SQL> commit;
SQL> insert into b.t values(2);
SQL> commit;
SQL> select current_scn from v$database;        【假设此时SCN2为:1141236】
 

★ 创建并注册测试数据库到catalog数据库

/////////////////////////////////////////////////////////
SQL> create tablespace catalog datafile 'c:/app/catalog.dbf' size 5M autoextend on;
SQL> create user catalog identified by catalog default tablespace catalog;
SQL> grant dba,recovery_catalog_owner to catalog;

[oracle]$ export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
[oracle]$ export NLS_LANG=AMERICAN_AMERICA.AL32UTF8                【英文】
[oracle]$ export NLS_LANG='SIMPLIFIED CHINESE_CHINA.AL32UTF8'    【中文】
[oracle]$ rman target / catalog catalog/[email protected]:1521/win
RMAN> create catalog;
RMAN> unregister database;
RMAN> register database;
RMAN> resync catalog;


★ 模拟TSPITR

/////////////////////////////////////////////////////////
※ 只恢复表空间A,让表1(A.T)恢复到SCN2之前的状态(即SCN1)此时表1只有2条数据“0”和“1”
※ 其他表空间不受影响,例如B表空间中的表2(B.T)中应该有3条数据“0”、“1”、“2”
※ TSPITR后需要手动将恢复的表空间online
RMAN> recover tablespace a until scn 1141231 auxiliary destination '/home/oracle/aux';
RMAN> sql 'alter tablespace a online';


★ 验证

/////////////////////////////////////////////////////////
SQL> select * from a.t;        【此时A.T表中数据应该为:0、1】
SQL> select * from b.t;        【此时B.T表中数据应该为:0、1、2】


★ 清理环境

/////////////////////////////////////////////////////////
※ 清理测试数据库服务器
SQL> drop user a cascade;
SQL> drop tablespace a including contents and datafiles;
SQL> drop user b cascade;
SQL> drop tablespace b including contents and datafiles;
[oracle]$ rm -rf /home/oracle/datafile
[oracle]$ rm -rf /home/oracle/aux


※ 清理catalog数据库服务器
SQL> drop user catalog cascade;
SQL> drop tablespace catalog including contents and datafiles;


★ 相关日志(中文版)

/////////////////////////////////////////////////////////

[oracle@localhost ~]$ rlwrap rman target / catalog catalog/[email protected]:1521/win

恢复管理器: Release 11.2.0.3.0 - Production on 星期一 4月 27 22:29:05 2020

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

已连接到目标数据库: ORCL (DBID=1462754487)
连接到恢复目录数据库

RMAN> recover tablespace a until scn 1141231 auxiliary destination '/home/oracle/aux';

启动 recover 于 2020-04-27 22:17:59
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: SID=145 设备类型=DISK

使用 SID='fifl' 创建自动实例

供自动实例使用的初始化参数:
db_name=ORCL
db_unique_name=fifl_tspitr_ORCL
compatible=11.2.0.0.0
db_block_size=8192
db_files=200
sga_target=280M
processes=50
db_create_file_dest=/home/oracle/aux
log_archive_dest_1='location=/home/oracle/aux'
#No auxiliary parameter file used


启动自动实例 ORCL

Oracle 实例已启动

系统全局区域总计     292278272 字节

Fixed Size                     2227744 字节
Variable Size                100663776 字节
Database Buffers             184549376 字节
Redo Buffers                   4837376 字节
自动实例已创建
对恢复集表空间运行 TRANSPORT_SET_CHECK
TRANSPORT_SET_CHECK 已成功完成

内存脚本的内容:
{
# set requested point in time
set until  scn 1141231;
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log 
sql 'alter system archive log current';
# avoid unnecessary autobackups for structural changes during TSPITR
sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;';
# resync catalog
resync catalog;
}
正在执行内存脚本

正在执行命令: SET until clause

启动 restore 于 2020-04-27 22:18:10
分配的通道: ORA_AUX_DISK_1
通道 ORA_AUX_DISK_1: SID=58 设备类型=DISK

通道 ORA_AUX_DISK_1: 正在开始还原数据文件备份集
通道 ORA_AUX_DISK_1: 正在还原控制文件
通道 ORA_AUX_DISK_1: 正在读取备份片段 /u01/oracle/fast_recovery_area/ORCL/backupset/2020_04_27/o1_mf_ncsn0_TAG20200427T214258_hbfrd7lw_.bkp
通道 ORA_AUX_DISK_1: 段句柄 = /u01/oracle/fast_recovery_area/ORCL/backupset/2020_04_27/o1_mf_ncsn0_TAG20200427T214258_hbfrd7lw_.bkp 标记 = TAG20200427T214258
通道 ORA_AUX_DISK_1: 已还原备份片段 1
通道 ORA_AUX_DISK_1: 还原完成, 用时: 00:00:01
输出文件名=/home/oracle/aux/ORCL/controlfile/o1_mf_hbftf2vj_.ctl
完成 restore 于 2020-04-27 22:18:11

sql 语句: alter database mount clone database

sql 语句: alter system archive log current

sql 语句: begin dbms_backup_restore.AutoBackupFlag(FALSE); end;

正在启动全部恢复目录的 resync
完成全部 resync

内存脚本的内容:
{
# set requested point in time
set until  scn 1141231;
plsql <<<-- tspitr_2
declare
  sqlstatement       varchar2(512);
  offline_not_needed exception;
  pragma exception_init(offline_not_needed, -01539);
begin
  sqlstatement := 'alter tablespace '||  'A' ||' offline immediate';
  krmicd.writeMsg(6162, sqlstatement);
  krmicd.execSql(sqlstatement);
exception
  when offline_not_needed then
    null;
end; >>>;
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile  1 to new;
set newname for clone datafile  3 to new;
set newname for clone datafile  2 to new;
set newname for clone tempfile  1 to new;
set newname for datafile  5 to 
 "/home/oracle/datafile/a.dbf";
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile  1, 3, 2, 5;
switch clone datafile all;
}
正在执行内存脚本

正在执行命令: SET until clause

sql 语句: alter tablespace A offline immediate

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

临时文件 1 在控制文件中已重命名为 /home/oracle/aux/ORCL/datafile/o1_mf_temp_%u_.tmp

启动 restore 于 2020-04-27 22:18:18
使用通道 ORA_AUX_DISK_1

通道 ORA_AUX_DISK_1: 正在开始还原数据文件备份集
通道 ORA_AUX_DISK_1: 正在指定从备份集还原的数据文件
通道 ORA_AUX_DISK_1: 将数据文件 00001 还原到 /home/oracle/aux/ORCL/datafile/o1_mf_system_%u_.dbf
通道 ORA_AUX_DISK_1: 将数据文件 00003 还原到 /home/oracle/aux/ORCL/datafile/o1_mf_undotbs1_%u_.dbf
通道 ORA_AUX_DISK_1: 将数据文件 00002 还原到 /home/oracle/aux/ORCL/datafile/o1_mf_sysaux_%u_.dbf
通道 ORA_AUX_DISK_1: 将数据文件 00005 还原到 /home/oracle/datafile/a.dbf
通道 ORA_AUX_DISK_1: 正在读取备份片段 /u01/oracle/fast_recovery_area/ORCL/backupset/2020_04_27/o1_mf_nnnd0_TAG20200427T214258_hbfrc38j_.bkp
通道 ORA_AUX_DISK_1: 段句柄 = /u01/oracle/fast_recovery_area/ORCL/backupset/2020_04_27/o1_mf_nnnd0_TAG20200427T214258_hbfrc38j_.bkp 标记 = TAG20200427T214258
通道 ORA_AUX_DISK_1: 已还原备份片段 1
通道 ORA_AUX_DISK_1: 还原完成, 用时: 00:00:26
完成 restore 于 2020-04-27 22:18:45

数据文件 1 已转换成数据文件副本
输入数据文件副本 RECID=4 STAMP=1038867525 文件名=/home/oracle/aux/ORCL/datafile/o1_mf_system_hbftfc90_.dbf
数据文件 3 已转换成数据文件副本
输入数据文件副本 RECID=5 STAMP=1038867525 文件名=/home/oracle/aux/ORCL/datafile/o1_mf_undotbs1_hbftfc95_.dbf
数据文件 2 已转换成数据文件副本
输入数据文件副本 RECID=6 STAMP=1038867525 文件名=/home/oracle/aux/ORCL/datafile/o1_mf_sysaux_hbftfc93_.dbf

内存脚本的内容:
{
# set requested point in time
set until  scn 1141231;
# online the datafiles restored or switched
sql clone "alter database datafile  1 online";
sql clone "alter database datafile  3 online";
sql clone "alter database datafile  2 online";
sql clone "alter database datafile  5 online";
# recover and open resetlogs
recover clone database tablespace  "A", "SYSTEM", "UNDOTBS1", "SYSAUX" delete archivelog;
alter clone database open resetlogs;
}
正在执行内存脚本

正在执行命令: SET until clause

sql 语句: alter database datafile  1 online

sql 语句: alter database datafile  3 online

sql 语句: alter database datafile  2 online

sql 语句: alter database datafile  5 online

启动 recover 于 2020-04-27 22:18:45
使用通道 ORA_AUX_DISK_1

正在开始介质的恢复

线程 1 序列 10 的归档日志已作为文件 /u01/oracle/fast_recovery_area/ORCL/archivelog/2020_04_27/o1_mf_1_10_hbftf877_.arc 存在于磁盘上
归档日志文件名=/u01/oracle/fast_recovery_area/ORCL/archivelog/2020_04_27/o1_mf_1_10_hbftf877_.arc 线程=1 序列=10
介质恢复完成, 用时: 00:00:00
完成 recover 于 2020-04-27 22:18:46

数据库已打开

内存脚本的内容:
{
# make read only the tablespace that will be exported
sql clone 'alter tablespace  A read only';
# create directory for datapump import
sql "create or replace directory TSPITR_DIROBJ_DPDIR as ''
/home/oracle/aux''";
# create directory for datapump export
sql clone "create or replace directory TSPITR_DIROBJ_DPDIR as ''
/home/oracle/aux''";
}
正在执行内存脚本

sql 语句: alter tablespace  A read only

sql 语句: create or replace directory TSPITR_DIROBJ_DPDIR as ''/home/oracle/aux''

sql 语句: create or replace directory TSPITR_DIROBJ_DPDIR as ''/home/oracle/aux''

正在执行元数据导出...
   EXPDP> 启动 "SYS"."TSPITR_EXP_fifl":  
   EXPDP> 处理对象类型 TRANSPORTABLE_EXPORT/PLUGTS_BLK
   EXPDP> 处理对象类型 TRANSPORTABLE_EXPORT/TABLE
   EXPDP> 处理对象类型 TRANSPORTABLE_EXPORT/TABLE_STATISTICS
   EXPDP> 处理对象类型 TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
   EXPDP> 已成功加载/卸载了主表 "SYS"."TSPITR_EXP_fifl" 
   EXPDP> ******************************************************************************
   EXPDP> SYS.TSPITR_EXP_fifl 的转储文件集为:
   EXPDP>   /home/oracle/aux/tspitr_fifl_28927.dmp
   EXPDP> ******************************************************************************
   EXPDP> 可传输表空间 A 所需的数据文件:
   EXPDP>   /home/oracle/datafile/a.dbf
   EXPDP> 作业 "SYS"."TSPITR_EXP_fifl" 已于 22:20:13 成功完成
导出完毕


内存脚本的内容:
{
# shutdown clone before import
shutdown clone immediate
# drop target tablespaces before importing them back
sql 'drop tablespace  A including contents keep datafiles';
}
正在执行内存脚本

数据库已关闭
数据库已卸装
Oracle 实例已关闭

sql 语句: drop tablespace  A including contents keep datafiles

正在执行元数据导入...
   IMPDP> 已成功加载/卸载了主表 "SYS"."TSPITR_IMP_fifl" 
   IMPDP> 启动 "SYS"."TSPITR_IMP_fifl":  
   IMPDP> 处理对象类型 TRANSPORTABLE_EXPORT/PLUGTS_BLK
   IMPDP> 处理对象类型 TRANSPORTABLE_EXPORT/TABLE
   IMPDP> 处理对象类型 TRANSPORTABLE_EXPORT/TABLE_STATISTICS
   IMPDP> 处理对象类型 TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
   IMPDP> 作业 "SYS"."TSPITR_IMP_fifl" 已于 22:20:31 成功完成
导入完毕


内存脚本的内容:
{
# make read write and offline the imported tablespaces
sql 'alter tablespace  A read write';
sql 'alter tablespace  A offline';
# enable autobackups after TSPITR is finished
sql 'begin dbms_backup_restore.AutoBackupFlag(TRUE); end;';
# resync catalog
resync catalog;
}
正在执行内存脚本

sql 语句: alter tablespace  A read write

sql 语句: alter tablespace  A offline

sql 语句: begin dbms_backup_restore.AutoBackupFlag(TRUE); end;

正在启动全部恢复目录的 resync
完成全部 resync

删除自动实例
自动实例已删除
已删除辅助实例文件 /home/oracle/aux/ORCL/datafile/o1_mf_temp_hbftgbqr_.tmp
已删除辅助实例文件 /home/oracle/aux/ORCL/onlinelog/o1_mf_3_hbftg91f_.log
已删除辅助实例文件 /home/oracle/aux/ORCL/onlinelog/o1_mf_2_hbftg7jz_.log
已删除辅助实例文件 /home/oracle/aux/ORCL/onlinelog/o1_mf_1_hbftg6go_.log
已删除辅助实例文件 /home/oracle/aux/ORCL/datafile/o1_mf_sysaux_hbftfc93_.dbf
已删除辅助实例文件 /home/oracle/aux/ORCL/datafile/o1_mf_undotbs1_hbftfc95_.dbf
已删除辅助实例文件 /home/oracle/aux/ORCL/datafile/o1_mf_system_hbftfc90_.dbf
已删除辅助实例文件 /home/oracle/aux/ORCL/controlfile/o1_mf_hbftf2vj_.ctl
完成 recover 于 2020-04-27 22:20:34

RMAN> 


★ 相关日志(英文版)

/////////////////////////////////////////////////////////

[oracle@localhost ~]$ rlwrap rman target / catalog catalog/[email protected]:1521/win

Recovery Manager: Release 11.2.0.3.0 - Production on Mon Apr 27 22:25:56 2020

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1462754487)
connected to recovery catalog database

RMAN> recover tablespace a until scn 1141231 auxiliary destination '/home/oracle/aux';

Starting recover at 2020-04-27 22:25:59
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=22 device type=DISK

Creating automatic instance, with SID='kgfD'

initialization parameters used for automatic instance:
db_name=ORCL
db_unique_name=kgfD_tspitr_ORCL
compatible=11.2.0.0.0
db_block_size=8192
db_files=200
sga_target=280M
processes=50
db_create_file_dest=/home/oracle/aux
log_archive_dest_1='location=/home/oracle/aux'
#No auxiliary parameter file used


starting up automatic instance ORCL

Oracle instance started

Total System Global Area     292278272 bytes

Fixed Size                     2227744 bytes
Variable Size                100663776 bytes
Database Buffers             184549376 bytes
Redo Buffers                   4837376 bytes
Automatic instance created
Running TRANSPORT_SET_CHECK on recovery set tablespaces
TRANSPORT_SET_CHECK completed successfully

contents of Memory Script:
{
# set requested point in time
set until  scn 1141231;
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log 
sql 'alter system archive log current';
# avoid unnecessary autobackups for structural changes during TSPITR
sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;';
# resync catalog
resync catalog;
}
executing Memory Script

executing command: SET until clause

Starting restore at 2020-04-27 22:26:09
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=58 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /u01/oracle/fast_recovery_area/ORCL/backupset/2020_04_27/o1_mf_ncsn0_TAG20200427T214258_hbfrd7lw_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/oracle/fast_recovery_area/ORCL/backupset/2020_04_27/o1_mf_ncsn0_TAG20200427T214258_hbfrd7lw_.bkp tag=TAG20200427T214258
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/home/oracle/aux/ORCL/controlfile/o1_mf_hbftw234_.ctl
Finished restore at 2020-04-27 22:26:11

sql statement: alter database mount clone database

sql statement: alter system archive log current

sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end;

starting full resync of recovery catalog
full resync complete

contents of Memory Script:
{
# set requested point in time
set until  scn 1141231;
plsql <<<-- tspitr_2
declare
  sqlstatement       varchar2(512);
  offline_not_needed exception;
  pragma exception_init(offline_not_needed, -01539);
begin
  sqlstatement := 'alter tablespace '||  'A' ||' offline immediate';
  krmicd.writeMsg(6162, sqlstatement);
  krmicd.execSql(sqlstatement);
exception
  when offline_not_needed then
    null;
end; >>>;
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile  1 to new;
set newname for clone datafile  3 to new;
set newname for clone datafile  2 to new;
set newname for clone tempfile  1 to new;
set newname for datafile  5 to 
 "/home/oracle/datafile/a.dbf";
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile  1, 3, 2, 5;
switch clone datafile all;
}
executing Memory Script

executing command: SET until clause

sql statement: alter tablespace A offline immediate

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

renamed tempfile 1 to /home/oracle/aux/ORCL/datafile/o1_mf_temp_%u_.tmp in control file

Starting restore at 2020-04-27 22:26:17
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /home/oracle/aux/ORCL/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /home/oracle/aux/ORCL/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /home/oracle/aux/ORCL/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00005 to /home/oracle/datafile/a.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/oracle/fast_recovery_area/ORCL/backupset/2020_04_27/o1_mf_nnnd0_TAG20200427T214258_hbfrc38j_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/oracle/fast_recovery_area/ORCL/backupset/2020_04_27/o1_mf_nnnd0_TAG20200427T214258_hbfrc38j_.bkp tag=TAG20200427T214258
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:25
Finished restore at 2020-04-27 22:26:42

datafile 1 switched to datafile copy
input datafile copy RECID=4 STAMP=1038868002 file name=/home/oracle/aux/ORCL/datafile/o1_mf_system_hbftw9t9_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=5 STAMP=1038868003 file name=/home/oracle/aux/ORCL/datafile/o1_mf_undotbs1_hbftw9tj_.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=6 STAMP=1038868003 file name=/home/oracle/aux/ORCL/datafile/o1_mf_sysaux_hbftw9td_.dbf

contents of Memory Script:
{
# set requested point in time
set until  scn 1141231;
# online the datafiles restored or switched
sql clone "alter database datafile  1 online";
sql clone "alter database datafile  3 online";
sql clone "alter database datafile  2 online";
sql clone "alter database datafile  5 online";
# recover and open resetlogs
recover clone database tablespace  "A", "SYSTEM", "UNDOTBS1", "SYSAUX" delete archivelog;
alter clone database open resetlogs;
}
executing Memory Script

executing command: SET until clause

sql statement: alter database datafile  1 online

sql statement: alter database datafile  3 online

sql statement: alter database datafile  2 online

sql statement: alter database datafile  5 online

Starting recover at 2020-04-27 22:26:43
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 10 is already on disk as file /u01/oracle/fast_recovery_area/ORCL/archivelog/2020_04_27/o1_mf_1_10_hbftf877_.arc
archived log file name=/u01/oracle/fast_recovery_area/ORCL/archivelog/2020_04_27/o1_mf_1_10_hbftf877_.arc thread=1 sequence=10
media recovery complete, elapsed time: 00:00:01
Finished recover at 2020-04-27 22:26:44

database opened

contents of Memory Script:
{
# make read only the tablespace that will be exported
sql clone 'alter tablespace  A read only';
# create directory for datapump import
sql "create or replace directory TSPITR_DIROBJ_DPDIR as ''
/home/oracle/aux''";
# create directory for datapump export
sql clone "create or replace directory TSPITR_DIROBJ_DPDIR as ''
/home/oracle/aux''";
}
executing Memory Script

sql statement: alter tablespace  A read only

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/home/oracle/aux''

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/home/oracle/aux''

Performing export of metadata...
   EXPDP> Starting "SYS"."TSPITR_EXP_kgfD":  
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
   EXPDP> Master table "SYS"."TSPITR_EXP_kgfD" successfully loaded/unloaded
   EXPDP> ******************************************************************************
   EXPDP> Dump file set for SYS.TSPITR_EXP_kgfD is:
   EXPDP>   /home/oracle/aux/tspitr_kgfD_99085.dmp
   EXPDP> ******************************************************************************
   EXPDP> Datafiles required for transportable tablespace A:
   EXPDP>   /home/oracle/datafile/a.dbf
   EXPDP> Job "SYS"."TSPITR_EXP_kgfD" successfully completed at 22:27:48
Export completed


contents of Memory Script:
{
# shutdown clone before import
shutdown clone immediate
# drop target tablespaces before importing them back
sql 'drop tablespace  A including contents keep datafiles';
}
executing Memory Script

database closed
database dismounted
Oracle instance shut down

sql statement: drop tablespace  A including contents keep datafiles

Performing import of metadata...
   IMPDP> Master table "SYS"."TSPITR_IMP_kgfD" successfully loaded/unloaded
   IMPDP> Starting "SYS"."TSPITR_IMP_kgfD":  
   IMPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
   IMPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE
   IMPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
   IMPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
   IMPDP> Job "SYS"."TSPITR_IMP_kgfD" successfully completed at 22:28:05
Import completed


contents of Memory Script:
{
# make read write and offline the imported tablespaces
sql 'alter tablespace  A read write';
sql 'alter tablespace  A offline';
# enable autobackups after TSPITR is finished
sql 'begin dbms_backup_restore.AutoBackupFlag(TRUE); end;';
# resync catalog
resync catalog;
}
executing Memory Script

sql statement: alter tablespace  A read write

sql statement: alter tablespace  A offline

sql statement: begin dbms_backup_restore.AutoBackupFlag(TRUE); end;

starting full resync of recovery catalog
full resync complete

Removing automatic instance
Automatic instance removed
auxiliary instance file /home/oracle/aux/ORCL/datafile/o1_mf_temp_hbftx6s6_.tmp deleted
auxiliary instance file /home/oracle/aux/ORCL/onlinelog/o1_mf_3_hbftx5q7_.log deleted
auxiliary instance file /home/oracle/aux/ORCL/onlinelog/o1_mf_2_hbftx504_.log deleted
auxiliary instance file /home/oracle/aux/ORCL/onlinelog/o1_mf_1_hbftx45b_.log deleted
auxiliary instance file /home/oracle/aux/ORCL/datafile/o1_mf_sysaux_hbftw9td_.dbf deleted
auxiliary instance file /home/oracle/aux/ORCL/datafile/o1_mf_undotbs1_hbftw9tj_.dbf deleted
auxiliary instance file /home/oracle/aux/ORCL/datafile/o1_mf_system_hbftw9t9_.dbf deleted
auxiliary instance file /home/oracle/aux/ORCL/controlfile/o1_mf_hbftw234_.ctl deleted
Finished recover at 2020-04-27 22:28:09

RMAN> 

※ 如果您觉得文章写的还不错, 别忘了在文末给作者点个赞哦 ~

over

原创文章 53 获赞 52 访问量 5013

猜你喜欢

转载自blog.csdn.net/zzt_2009/article/details/105801779