【12c】12c RMAN新特性之recover table(表级别恢复)
在 RMAN 中提供了表级别恢复( RECOVER TABLE )。在 Oracle 12c 中,在发生 drop 或 truncate 的情况下,可以从 RMAN 备份种将一个特定的表或分区恢复到某个时间点、 SCN 或归档序列号,并且可以有下面的选择:
l 使用REMAP选项将表恢复为一个新表或者分区中,也可以恢复到其他用户中。
l 只生成一个需要被恢复表的expdp格式的dump文件,选择后期再进行恢复。
Oracle 12c的Recover Table新特性是利用创建辅助临时实例加数据泵工具来实现的。通常在进行Recover Table之前应该准备好两个目录(AUXILIARY DESTINATION和DATAPUMP DESTINATION),AUXILIARY DESTINATION用来临时存放辅助实例的数据文件,DATAPUMP DESTINATION用来临时存放数据泵导出的文件。
只要之前创建了RMAN备份,那么就可以根据指定的的时间来进行表级和表分区级的恢复操作,而且不影响其他的数据库对象。RMAN的表级和表分区级恢复可以使用在如下场景:
① 在恢复小表或数据库中的某几张表时,但发现使用Restore Database或Tablespace的代价很高而且效率很低。也可以使用TSPITR(表空间基于时间点的恢复)的方法,但该方法效率很低,因为需要移动表空间中的所有对象。
② 恢复有逻辑损坏或者被删除的表。
③ Flashback Table不可用,例如Undo数据已经被覆盖的情况。
④ DDL操作后需要恢复数据。Flashback Table不支持表结构发生改变后的回退,例如TRUNCATE TABLE。
RMAN从备份中自动处理恢复表或者表分区时会执行如下步骤:
1.判断哪些备份包含需要恢复的表或表分区,然后根据指定的时间来进行恢复。
2.判断目标主机上是否有足够的空间来创建auxiliary instance,该实例用于处理表或分区的恢复。如果需要的空间不足,那么RMAN会报错并退出恢复操作。
3.创建auxiliary database,并根据指定的时间来恢复指定的表或表分区到auxiliary database中。辅助数据库的数据文件位置可以在命令中指定。
4.创建包含恢复表或表分区的数据泵文件(expdp dump file)。数据泵的名称和位置也可以在命令中指定。
5.(可选操作)将上一步生产的数据泵文件导入到目标实例中。当然也可以选择不导入,如果选择不导入就必须使用impdp手工导入。
6.(可选操作)在目标数据库中rename恢复表或表分区。
关于RECOVER TABLE需要注意的几个问题:
l 目标数据库必须被置于读写模式。
l 目标数据库必须被置于归档模式。
l 如果要恢复表或者分区,你必须拥有这些表或者分区存在后的时间的备份。
l 想要恢复单个表分区,COMPATIBLE初始化参数所在的目标库必须设置为11.1.0或以上。
l SYS用户下的表或分区无法恢复。
l 存储于SYSAUX和SYSTEM表空间下的表和分区无法恢复。
l Standby数据库上的表或表分区不能进行恢复。
l 在使用REMAP的情况下,有NOT NULL 约束的表不能进行恢复。
l 确保对于辅助数据库在文件系统下有足够的可用空间,同时对数据泵文件也有同样保证。
l 必须要存在一份完整的数据库备份,至少要有SYSTEM、UNDO、SYSAUX和表所在表空间相关的备份。如果恢复的表在PDB中,那么需要备份Root Container的SYSTEM,SYSAUX、UNDO和PDB的SYSTEM、SYSAUX以及包含了要恢复的表的表空间。
在执行“RECOVER TABLE”命令时,可以根据需要在以下三种级别指定时间:
(1)SCN号
(2)Sequence number(日志序列号)
(3)Time:根据NLS_LANG和NLS_DATE_FORMAT环境变量中的格式来指定时间,也可以用SYSDATE,比如"SYSDATE-30"、"to_date('2018-04-09:13:51:48','yyyy-mm-dd hh24:mi:ss')"
“RECOVER TABLE”命令的一般格式为:
RMAN> connect target "username/password as SYSBACKUP";
RMAN> RECOVER TABLE username.tablename UNTIL TIME 'TIMESTAMP…'
AUXILIARY DESTINATION '/u01/tablerecovery'
DATAPUMP DESTINATION '/u01/dpump'
DUMP FILE 'tablename.dmp'
NOTABLEIMPORT -- this option avoids importing the table automatically.(此选项避免自动导入表)
REMAP TABLE 'username.tablename': 'username.new_table_name'; -- can rename table with this option.(此选项可以对表重命名)
示例1:在PDB中恢复表HR.PDB_EMP,恢复后的表命名为EMP_RECVR
RECOVER TABLE HR.PDB_EMP OF PLUGGABLE DATABASE HR_PDB
UNTIL TIME 'SYSDATE-4'
AUXILIARY DESTINATION '/tmp/backups'
REMAP TABLE 'HR'.'PDB_EMP':'EMP_RECVR';
RECOVER TABLE DB12C.T
UNTIL SCN 1932621
AUXILIARY DESTINATION '/tmp/oracle/recover'
REMAP TABLE 'DB12C'.'T':'T_HISTORY_20130717';
RECOVER TABLE LHR.TEST_RT
UNTIL TIME "to_date('2018-04-09:13:51:48','yyyy-mm-dd hh24:mi:ss')"
AUXILIARY DESTINATION '/tmp'
REMAP TABLE 'LHR'.'TEST_RT':'TEST_RT_LHR';
RECOVER TABLE HR.DEPARTMENTS, SH.CHANNELS
UNTIL TIME 'SYSDATE – 1'
AUXILIARY DESTINATION '/tmp/auxdest'
REMAP TABLE hr.departments:example.new_departments, sh.channels:example.new_channels;
示例2:从RMAN备份中恢复表SCOTT.EMP,SCOTT.DEPT,并以数据泵格式导出emp_dept_exp_dump.dat,并不进行表的导入
RECOVER TABLE SCOTT.EMP, SCOTT.DEPT
UNTIL TIME 'SYSDATE-1'
AUXILIARY DESTINATION '/tmp/oracle/recover'
DATAPUMP DESTINATION '/tmp/recover/dumpfiles'
DUMP FILE 'emp_dept_exp_dump.dat'
NOTABLEIMPORT;
示例3:恢复表的两个分区,恢复后表分区重新命名并且放置于SALES_PRE_2000_TS表空间
RECOVER TABLE SH.SALES:SALES_1998, SH.SALES:SALES_1999
UNTIL SEQUENCE 354
AUXILIARY DESTINATION '/tmp/oracle/recover'
REMAP TABLE 'SH'.'SALES':'SALES_1998':'HISTORIC_SALES_1998',
'SH'.'SALES':'SALES_1999':'HISTORIC_SALES_1999'
REMAP TABLESPACE 'SALES_TS':'SALES_PRE_2000_TS';
https://docs.oracle.com/database/121/BRADV/rcmresind.htm#BRADV703
https://www.cnblogs.com/andy6/p/6884320.html
http://www.xifenfei.com/2013/03/oracle-12c-rman-recover-table.html
http://www.askmaclean.com/archives/12c%E6%96%B0%E7%89%B9%E6%80%A7recover-table.html
http://www.cndba.cn/dave/article/1871
http://blog.itpub.net/26753337/viewspace-2107978/
Oracle 12c 新特性:RMAN Recover Table 详解
1. Recover Table 和 Table Partitions概述
Oracle 从12c开始支持在RMAN 中进行表级的恢复操作,即对单表进行recover。官方文档链接如下:
http://docs.oracle.com/database/122/BRADV/rman-recovering-tables-partitions.htm
RMAN的表级和表分区级恢复可以使用在如下场景:
1. 恢复小表时。也可以使用TSPITR 的方法,但该方法效率很低,因为需要移动表空间中的所有对象。
2. 恢复有逻辑损坏或者被删除的表。
3. Flashback Table 不可用,比如undo 数据已经被覆盖。
4. DDL 操作后需要恢复数据。Flashback Table 不支持表结构发生改变后的回退。 比如truncate table。
只要之前创建了RMAN 备份,就可以根据指定的的时间来进行表级和表分区级的恢复操作,而且不影响其他的数据库对象。
可以根据在以下三种级别指定时间:
(1) SCN
(2) Sequence number
(3) Time:根据 NLS_LANG 和 NLS_DATE_FORMAT 环境变量中的格式来指定时间,也可以用SYSDATE,比如 SYSDATE-30.
为了恢复表或者表分区, 需要备份undo,SYSTEM,SYSAUX和包含表或者表分区的表空间。
如果恢复的表在PDB中,那么需要备份如下内容:
1. Root的SYSTEM,SYSAUX 和undo 表空间,SEED,以及包含表的PDB。
2. 包含表或分区的表空间
当然恢复表或者表分区也有限制条件,以下情况不能使用:
1. SYS 用户的表或表分区不能进行恢复
2. SYSTEM 和SYSAUX 表空间中的表或表分区不能进行恢复。
3. Standby 数据库上的表或表分区不能进行恢复。
4. 在使用REMAP 的情况下,有NOT NULL 约束的表不能进行恢复。
RMAN从备份中自动处理恢复表或者表分区时会执行如下步骤:
1.判断哪些备份包含需要恢复的表或表分区,然后根据指定的时间来进行恢复。
2.判断目标主机上是否有足够的空间来创建auxiliary instance,该实例用于处理表或分区的恢复。 如果需要的空间不足,那么RMAN 会报错并退出恢复操作。
3.创建auxiliary database,并根据指定的时间来恢复指定的表或表分区到auxiliary database中。 辅助数据库的数据文件位置可以在命令中指定。
4.创建包含恢复表或表分区的数据泵文件(expdp dump file)。 数据泵的名称和位置也可以在命令中指定。
5. (可选操作)将上一步生产的数据泵文件导入到目标实例中。当然也可以选择不导入,如果选择不导入就必须使用impdp 手工导入。
6. (可选操作)在目标数据库中rename 恢复表或表分区。
2 PDB操作示例
2.1 准备测试环境
因为特性不支持系统用户和表,所以需要先创建独立的用户和表空间:
oracle@www.cndba.cn ~]$ sqlplus / as sysdba SQL*Plus: Release 12.2.0.1.0 Production on Sun Apr 16 23:24:44 2017 Copyright (c) 1982, 2016, Oracle. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production SQL> show con_name CON_NAME ------------------------------ CDB$ROOT SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 DAVE READ WRITE NO SQL> alter session set container=DAVE; Session altered. SQL> create tablespace lotus datafile '/dave/app/oracle/oradata/cndba/dave/lotus01.dbf' size 20m; Tablespace created. SQL> create user lotus identified by lotus default tablespace lotus; User created. SQL> grant resource,connect,dba to lotus; Grant succeeded. --创建测试表: SQL> conn lotus/lotus@dave Connected. SQL> create table cndba as select * from dba_objects; Table created. SQL> select count(1) from cndba; COUNT(1) ---------- 72636 SQL> conn / as sysdba Connected. SQL> alter system switch logfile; System altered. SQL> alter system switch logfile; System altered.
2.2 RMAN 备份CDB
--使用如下命令备份CDB的组建:ROOT,SEED,PDBS:
RMAN> backup database plus archivelog;
具体过程省略,第一小节已有说明,在PDB 中必须备份ROOT,SEED,和所有的PDBS.
2.3 恢复数据
现在drop cndba 表,然后执行恢复操作:
SQL> conn lotus/lotus@dave Connected. SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual; TO_CHAR(SYSDATE,'YY ------------------- 2017-04-17 10:20:49 SQL> drop table cndba;
注意这里只能是drop,truncate不能recover。 如果是truncate,那么就不能执行导入操作。
注意在链接RMAN 时需要连接到root,并且具有SYSDBA 或 SYSBACKUP 权限。
可以使用rman target sys 或 rman target /(The connection is established as the SYS user with SYSDBA privilege)
[oracle@www.cndba.cn cndba]$ mkdir -p /tmp/oracle/recover [oracle@www.cndba.cn cndba]$ mkdir -p /tmp/recover/dumpfiles
恢复过程:还原system,undo,sysaux表空间,然后read only数据库,然后重启数据库还原表所在表空间,然后expdp导出表,根据需要决定是否导入表到原PDB数据库中,最后删除辅助数据库。 整个过程对原PDB没有影响。
恢复命令如下:
recover table lotus.cndba of pluggable database dave until time "to_date('2017-04-17 10:20:49','yyyy-mm-dd hh24:mi:ss')" auxiliary destination '/tmp/oracle/recover' datapump destination '/tmp/recover/dumpfiles' dump file 'www.cndba.cn.dat';
大致过程:
Creating automatic instance, with SID='ajrg' ----- 这里开始创建 auxiliary instance
Starting restore at 17-APR-17 ----- 先 restore database
Starting recover at 17-APR-17 ---- 再 recover
# create directory for datapump import ----- 使用数据泵导出相关数据
Performing import of tables... ------- 向 target database 导入数据
Removing automatic instance
Automatic instance removed ------ 删除环境
完整log:
RMAN> recover table lotus.cndba of pluggable database dave until time "to_date('2017-04-17 10:20:49','yyyy-mm-dd hh24:mi:ss')" auxiliary destination '/tmp/oracle/recover' datapump destination '/tmp/recover/dumpfiles' dump file 'www.cndba.cn.dat'; 2> 3> 4> 5> Starting recover at 17-APR-17 using channel ORA_DISK_1 RMAN-05026: warning: presuming following set of tablespaces applies to specified point-in-time List of tablespaces expected to have UNDO segments Tablespace SYSTEM Tablespace DAVE:SYSTEM Tablespace UNDOTBS1 Tablespace DAVE:UNDOTBS1 Creating automatic instance, with SID='ajrg' initialization parameters used for automatic instance: db_name=CNDBA db_unique_name=ajrg_pitr_dave_CNDBA compatible=12.2.0 db_block_size=8192 db_files=200 diagnostic_dest=/dave/app/oracle _system_trig_enabled=FALSE sga_target=2000M processes=200 db_create_file_dest=/tmp/oracle/recover log_archive_dest_1='location=/tmp/oracle/recover' enable_pluggable_database=true _clone_one_pdb_recovery=true #No auxiliary parameter file used starting up automatic instance CNDBA Oracle instance started Total System Global Area 2097152000 bytes Fixed Size 8794696 bytes Variable Size 503319992 bytes Database Buffers 1577058304 bytes Redo Buffers 7979008 bytes Automatic instance created contents of Memory Script: { # set requested point in time set until time "to_date('2017-04-17 10:20:49','yyyy-mm-dd hh24:mi:ss')"; # 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'; } executing Memory Script executing command: SET until clause Starting restore at 17-APR-17 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=244 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 /dave/app/oracle/recovery_area/CNDBA/autobackup/2017_04_17/o1_mf_s_941537994_dh89lcs6_.bkp channel ORA_AUX_DISK_1: piece handle=/dave/app/oracle/recovery_area/CNDBA/autobackup/2017_04_17/o1_mf_s_941537994_dh89lcs6_.bkp tag=TAG20170417T101954 channel ORA_AUX_DISK_1: restored backup piece 1 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01 output file name=/tmp/oracle/recover/CNDBA/controlfile/o1_mf_dh8brc7q_.ctl Finished restore at 17-APR-17 sql statement: alter database mount clone database sql statement: alter system archive log current contents of Memory Script: { # set requested point in time set until time "to_date('2017-04-17 10:20:49','yyyy-mm-dd hh24:mi:ss')"; # set destinations for recovery set and auxiliary set datafiles set newname for clone datafile 1 to new; set newname for clone datafile 9 to new; set newname for clone datafile 4 to new; set newname for clone datafile 11 to new; set newname for clone datafile 3 to new; set newname for clone datafile 10 to new; set newname for clone tempfile 1 to new; set newname for clone tempfile 3 to new; # switch all tempfiles switch clone tempfile all; # restore the tablespaces in the recovery set and the auxiliary set restore clone datafile 1, 9, 4, 11, 3, 10; switch clone datafile all; } executing Memory Script executing command: SET until clause executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME renamed tempfile 1 to /tmp/oracle/recover/CNDBA/datafile/o1_mf_temp_%u_.tmp in control file renamed tempfile 3 to /tmp/oracle/recover/CNDBA/4C0212A2559073AFE05515D212634C11/datafile/o1_mf_temp_%u_.tmp in control file Starting restore at 17-APR-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 /tmp/oracle/recover/CNDBA/datafile/o1_mf_system_%u_.dbf channel ORA_AUX_DISK_1: restoring datafile 00004 to /tmp/oracle/recover/CNDBA/datafile/o1_mf_undotbs1_%u_.dbf channel ORA_AUX_DISK_1: restoring datafile 00003 to /tmp/oracle/recover/CNDBA/datafile/o1_mf_sysaux_%u_.dbf channel ORA_AUX_DISK_1: reading from backup piece /dave/app/oracle/recovery_area/CNDBA/backupset/2017_04_17/o1_mf_nnndf_TAG20170417T101904_dh89jsk0_.bkp channel ORA_AUX_DISK_1: piece handle=/dave/app/oracle/recovery_area/CNDBA/backupset/2017_04_17/o1_mf_nnndf_TAG20170417T101904_dh89jsk0_.bkp tag=TAG20170417T101904 channel ORA_AUX_DISK_1: restored backup piece 1 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15 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 00009 to /tmp/oracle/recover/CNDBA/4C0212A2559073AFE05515D212634C11/datafile/o1_mf_system_%u_.dbf channel ORA_AUX_DISK_1: restoring datafile 00011 to /tmp/oracle/recover/CNDBA/4C0212A2559073AFE05515D212634C11/datafile/o1_mf_undotbs1_%u_.dbf channel ORA_AUX_DISK_1: restoring datafile 00010 to /tmp/oracle/recover/CNDBA/4C0212A2559073AFE05515D212634C11/datafile/o1_mf_sysaux_%u_.dbf channel ORA_AUX_DISK_1: reading from backup piece /dave/app/oracle/recovery_area/CNDBA/4C0212A2559073AFE05515D212634C11/backupset/2017_04_17/o1_mf_nnndf_TAG20170417T101904_dh89k8lc_.bkp channel ORA_AUX_DISK_1: piece handle=/dave/app/oracle/recovery_area/CNDBA/4C0212A2559073AFE05515D212634C11/backupset/2017_04_17/o1_mf_nnndf_TAG20170417T101904_dh89k8lc_.bkp tag=TAG20170417T101904 channel ORA_AUX_DISK_1: restored backup piece 1 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07 Finished restore at 17-APR-17 datafile 1 switched to datafile copy input datafile copy RECID=10 STAMP=941539242 file name=/tmp/oracle/recover/CNDBA/datafile/o1_mf_system_dh8brn6g_.dbf datafile 9 switched to datafile copy input datafile copy RECID=11 STAMP=941539242 file name=/tmp/oracle/recover/CNDBA/4C0212A2559073AFE05515D212634C11/datafile/o1_mf_system_dh8bs39k_.dbf datafile 4 switched to datafile copy input datafile copy RECID=12 STAMP=941539242 file name=/tmp/oracle/recover/CNDBA/datafile/o1_mf_undotbs1_dh8brn8q_.dbf datafile 11 switched to datafile copy input datafile copy RECID=13 STAMP=941539242 file name=/tmp/oracle/recover/CNDBA/4C0212A2559073AFE05515D212634C11/datafile/o1_mf_undotbs1_dh8bs3bb_.dbf datafile 3 switched to datafile copy input datafile copy RECID=14 STAMP=941539242 file name=/tmp/oracle/recover/CNDBA/datafile/o1_mf_sysaux_dh8brn7p_.dbf datafile 10 switched to datafile copy input datafile copy RECID=15 STAMP=941539242 file name=/tmp/oracle/recover/CNDBA/4C0212A2559073AFE05515D212634C11/datafile/o1_mf_sysaux_dh8bs37y_.dbf contents of Memory Script: { # set requested point in time set until time "to_date('2017-04-17 10:20:49','yyyy-mm-dd hh24:mi:ss')"; # online the datafiles restored or switched sql clone "alter database datafile 1 online"; sql clone 'DAVE' "alter database datafile 9 online"; sql clone "alter database datafile 4 online"; sql clone 'DAVE' "alter database datafile 11 online"; sql clone "alter database datafile 3 online"; sql clone 'DAVE' "alter database datafile 10 online"; # recover and open database read only recover clone database tablespace "SYSTEM", "DAVE":"SYSTEM", "UNDOTBS1", "DAVE":"UNDOTBS1", "SYSAUX", "DAVE":"SYSAUX"; sql clone 'alter database open read only'; } executing Memory Script executing command: SET until clause sql statement: alter database datafile 1 online sql statement: alter database datafile 9 online sql statement: alter database datafile 4 online sql statement: alter database datafile 11 online sql statement: alter database datafile 3 online sql statement: alter database datafile 10 online Starting recover at 17-APR-17 using channel ORA_AUX_DISK_1 starting media recovery archived log for thread 1 with sequence 15 is already on disk as file /dave/app/oracle/recovery_area/CNDBA/archivelog/2017_04_17/o1_mf_1_15_dh89l7vk_.arc archived log for thread 1 with sequence 16 is already on disk as file /dave/app/oracle/recovery_area/CNDBA/archivelog/2017_04_17/o1_mf_1_16_dh89or10_.arc archived log file name=/dave/app/oracle/recovery_area/CNDBA/archivelog/2017_04_17/o1_mf_1_15_dh89l7vk_.arc thread=1 sequence=15 archived log file name=/dave/app/oracle/recovery_area/CNDBA/archivelog/2017_04_17/o1_mf_1_16_dh89or10_.arc thread=1 sequence=16 media recovery complete, elapsed time: 00:00:04 Finished recover at 17-APR-17 sql statement: alter database open read only contents of Memory Script: { sql clone 'alter pluggable database DAVE open read only'; } executing Memory Script sql statement: alter pluggable database DAVE open read only contents of Memory Script: { sql clone "create spfile from memory"; shutdown clone immediate; startup clone nomount; sql clone "alter system set control_files = ''/tmp/oracle/recover/CNDBA/controlfile/o1_mf_dh8brc7q_.ctl'' comment= ''RMAN set'' scope=spfile"; shutdown clone immediate; startup clone nomount; # mount database sql clone 'alter database mount clone database'; } executing Memory Script sql statement: create spfile from memory database closed database dismounted Oracle instance shut down connected to auxiliary database (not started) Oracle instance started Total System Global Area 2097152000 bytes Fixed Size 8794696 bytes Variable Size 503319992 bytes Database Buffers 1577058304 bytes Redo Buffers 7979008 bytes sql statement: alter system set control_files = ''/tmp/oracle/recover/CNDBA/controlfile/o1_mf_dh8brc7q_.ctl'' comment= ''RMAN set'' scope=spfile Oracle instance shut down connected to auxiliary database (not started) Oracle instance started Total System Global Area 2097152000 bytes Fixed Size 8794696 bytes Variable Size 503319992 bytes Database Buffers 1577058304 bytes Redo Buffers 7979008 bytes sql statement: alter database mount clone database contents of Memory Script: { # set requested point in time set until time "to_date('2017-04-17 10:20:49','yyyy-mm-dd hh24:mi:ss')"; # set destinations for recovery set and auxiliary set datafiles set newname for datafile 13 to new; # restore the tablespaces in the recovery set and the auxiliary set restore clone datafile 13; switch clone datafile all; } executing Memory Script executing command: SET until clause executing command: SET NEWNAME Starting restore at 17-APR-17 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=244 device type=DISK 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 00013 to /tmp/oracle/recover/AJRG_PITR_DAVE_CNDBA/4C0212A2559073AFE05515D212634C11/datafile/o1_mf_lotus_%u_.dbf channel ORA_AUX_DISK_1: reading from backup piece /dave/app/oracle/recovery_area/CNDBA/4C0212A2559073AFE05515D212634C11/backupset/2017_04_17/o1_mf_nnndf_TAG20170417T101904_dh89k8lc_.bkp channel ORA_AUX_DISK_1: piece handle=/dave/app/oracle/recovery_area/CNDBA/4C0212A2559073AFE05515D212634C11/backupset/2017_04_17/o1_mf_nnndf_TAG20170417T101904_dh89k8lc_.bkp tag=TAG20170417T101904 channel ORA_AUX_DISK_1: restored backup piece 1 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01 Finished restore at 17-APR-17 datafile 13 switched to datafile copy input datafile copy RECID=17 STAMP=941539307 file name=/tmp/oracle/recover/AJRG_PITR_DAVE_CNDBA/4C0212A2559073AFE05515D212634C11/datafile/o1_mf_lotus_dh8bvbof_.dbf contents of Memory Script: { # set requested point in time set until time "to_date('2017-04-17 10:20:49','yyyy-mm-dd hh24:mi:ss')"; # online the datafiles restored or switched sql clone 'DAVE' "alter database datafile 13 online"; # recover and open resetlogs recover clone database tablespace "DAVE":"LOTUS", "SYSTEM", "DAVE":"SYSTEM", "UNDOTBS1", "DAVE":"UNDOTBS1", "SYSAUX", "DAVE":"SYSAUX" delete archivelog; alter clone database open resetlogs; } executing Memory Script executing command: SET until clause sql statement: alter database datafile 13 online Starting recover at 17-APR-17 using channel ORA_AUX_DISK_1 starting media recovery archived log for thread 1 with sequence 15 is already on disk as file /dave/app/oracle/recovery_area/CNDBA/archivelog/2017_04_17/o1_mf_1_15_dh89l7vk_.arc archived log for thread 1 with sequence 16 is already on disk as file /dave/app/oracle/recovery_area/CNDBA/archivelog/2017_04_17/o1_mf_1_16_dh89or10_.arc archived log file name=/dave/app/oracle/recovery_area/CNDBA/archivelog/2017_04_17/o1_mf_1_15_dh89l7vk_.arc thread=1 sequence=15 archived log file name=/dave/app/oracle/recovery_area/CNDBA/archivelog/2017_04_17/o1_mf_1_16_dh89or10_.arc thread=1 sequence=16 media recovery complete, elapsed time: 00:00:00 Finished recover at 17-APR-17 database opened contents of Memory Script: { sql clone 'alter pluggable database DAVE open'; } executing Memory Script sql statement: alter pluggable database DAVE open contents of Memory Script: { # create directory for datapump import sql 'DAVE' "create or replace directory TSPITR_DIROBJ_DPDIR as '' /tmp/recover/dumpfiles''"; # create directory for datapump export sql clone 'DAVE' "create or replace directory TSPITR_DIROBJ_DPDIR as '' /tmp/recover/dumpfiles''"; } executing Memory Script sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/tmp/recover/dumpfiles'' sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/tmp/recover/dumpfiles'' Performing export of tables... EXPDP> Starting "SYS"."TSPITR_EXP_ajrg_izmu": EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE EXPDP> . . exported "LOTUS"."CNDBA" 9.613 MB 72623 rows EXPDP> Master table "SYS"."TSPITR_EXP_ajrg_izmu" successfully loaded/unloaded EXPDP> ****************************************************************************** EXPDP> Dump file set for SYS.TSPITR_EXP_ajrg_izmu is: EXPDP> /tmp/recover/dumpfiles/www.cndba.cn.dat EXPDP> Job "SYS"."TSPITR_EXP_ajrg_izmu" successfully completed at Mon Apr 17 10:42:28 2017 elapsed 0 00:00:15 Export completed contents of Memory Script: { # shutdown clone before import shutdown clone abort } executing Memory Script Oracle instance shut down Performing import of tables... IMPDP> Master table "SYS"."TSPITR_IMP_ajrg_onBg" successfully loaded/unloaded IMPDP> Starting "SYS"."TSPITR_IMP_ajrg_onBg": IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA IMPDP> . . imported "LOTUS"."CNDBA" 9.613 MB 72623 rows IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER IMPDP> Job "SYS"."TSPITR_IMP_ajrg_onBg" successfully completed at Mon Apr 17 10:42:46 2017 elapsed 0 00:00:13 Import completed Removing automatic instance Automatic instance removed auxiliary instance file /tmp/oracle/recover/CNDBA/4C0212A2559073AFE05515D212634C11/datafile/o1_mf_temp_dh8bsmnd_.tmp deleted auxiliary instance file /tmp/oracle/recover/CNDBA/datafile/o1_mf_temp_dh8bslnq_.tmp deleted auxiliary instance file /tmp/oracle/recover/AJRG_PITR_DAVE_CNDBA/onlinelog/o1_mf_3_dh8bvhz2_.log deleted auxiliary instance file /tmp/oracle/recover/AJRG_PITR_DAVE_CNDBA/onlinelog/o1_mf_2_dh8bvhyt_.log deleted auxiliary instance file /tmp/oracle/recover/AJRG_PITR_DAVE_CNDBA/onlinelog/o1_mf_1_dh8bvhyk_.log deleted auxiliary instance file /tmp/oracle/recover/AJRG_PITR_DAVE_CNDBA/4C0212A2559073AFE05515D212634C11/datafile/o1_mf_lotus_dh8bvbof_.dbf deleted auxiliary instance file /tmp/oracle/recover/CNDBA/4C0212A2559073AFE05515D212634C11/datafile/o1_mf_sysaux_dh8bs37y_.dbf deleted auxiliary instance file /tmp/oracle/recover/CNDBA/datafile/o1_mf_sysaux_dh8brn7p_.dbf deleted auxiliary instance file /tmp/oracle/recover/CNDBA/4C0212A2559073AFE05515D212634C11/datafile/o1_mf_undotbs1_dh8bs3bb_.dbf deleted auxiliary instance file /tmp/oracle/recover/CNDBA/datafile/o1_mf_undotbs1_dh8brn8q_.dbf deleted auxiliary instance file /tmp/oracle/recover/CNDBA/4C0212A2559073AFE05515D212634C11/datafile/o1_mf_system_dh8bs39k_.dbf deleted auxiliary instance file /tmp/oracle/recover/CNDBA/datafile/o1_mf_system_dh8brn6g_.dbf deleted auxiliary instance file /tmp/oracle/recover/CNDBA/controlfile/o1_mf_dh8brc7q_.ctl deleted auxiliary instance file www.cndba.cn.dat deleted Finished recover at 17-APR-17 RMAN>
3 注意事项
3.1 说明1:PDB操作恢复的数据还在原PDB中生成
上面的示例是在PDB中演示的。 操作对象是单表,实际上对分区表中的单个分区也可以进行类似操作。
SQL> show con_name CON_NAME ------------------------------ DAVE SQL> select count(1) from cndba; COUNT(1) ---------- 72623 恢复的表还在原PDB中,中间产生的辅助数据库会在操作结束后删除。
3.2 说明2: RMAN-05112: table "LOTUS"."CNDBA" already exists
在PDB测试中 , 最开始的操作的时候,是对cndba表进行truncate 操作的。 但是执行recover时报错。 提示表已经存在,尝试remap,并未成功。 后来drop 掉表后成功recovoer。
当然也使用导出,添加notableimport参数不执行导入操作,然后再手工处理。
RMAN> recover table lotus.cndba of pluggable database dave until time "to_date('2017-04-17 10:20:49','yyyy-mm-dd hh24:mi:ss')" auxiliary destination '/tmp/oracle/recover' datapump destination '/tmp/recover/dumpfiles' remap table 'lotus'.' cndba':'cndba_2> 3> 4> 5> new'; dump file 'www.cndba.cn.dat'; Starting recover at 17-APR-17 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 04/17/2017 10:33:20 RMAN-05063: Cannot recover specified tables RMAN-05112: table "LOTUS"."CNDBA" already exists
3.3 说明3:ORA-01516: nonexistent log file 问题
第一次模拟的时候,recover 时报了数据文件不存在的问题。 实际上这个数据文件是我自己创建的。 后来换了个环境,重新备份后正常。 推测之前其他的rman 备份导致的异常。
auxiliary instance file /tmp/oracle/recover/CNDBA/controlfile/o1_mf_dh79n58l_.ctl deleted RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 04/17/2017 01:16:25 RMAN-03015: error occurred in stored script Memory Script RMAN-20505: create datafile during recovery RMAN-11003: failure during parse/execution of SQL statement: alter database datafile 17 offline ORA-01516: nonexistent log file, data file, or temporary file "17" in the current container RMAN-11003: failure during parse/execution of SQL statement: alter database recover logfile '/u01/app/oracle/recovery_area/CNDBA/archivelog/2017_04_17/o1_mf_1_19_dh79h697_.arc' ORA-00283: recovery session canceled due to errors ORA-01244: unnamed datafile(s) added to control file by media recovery ORA-01110: data file 17: '/u01/app/oracle/oradata/cndba/dave/lotus01.dbf'
3.4 说明4:non-CDB与PDB的区别
官网文档里还有另外一种写法,就是不带PDB 名称的。在CDB架构中测试的时候,会一直报RMAN-05057的错误:
recover table "c##lotus2".cndba until time "to_date('2017-04-17 11:03:49','yyyy-mm-dd hh24:mi:ss')" auxiliary destination '/tmp/oracle/recover' datapump destination '/tmp/recover/dumpfiles' dump file 'www.cndba.cn.dat'; 但尝试恢复一直报表不存在的错误: RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 04/17/2017 11:35:55 RMAN-05063: Cannot recover specified tables RMAN-05057: Table c##lotus2.CNDBA not found
仔细看了下官网,里面有提到non-cdb 情况,所以这种不带pdb名称的,应该是指这种non-cdb架构的环境。 就是普通的12c 数据库,非non-cdb 架构。 这里没有环境,不再去验证。
至少有一点可以确认,就是在CDB架构中,对PDB中的表进行操作recover table是没有问题的。
Oracle 12C 新特性之 恢复表
RMAN的表级和表分区级恢复应用场景:
1、You need to recover a very small number of tables to a particular point in time. In this situation, TSPITR is not the most effective solution because it moves all the objects in the tablespace to a specified point in time.
2、You need to recover tables that have been logically corrupted or have been dropped and purged.
3、Flashback Table is not possible because the desired point-in-time is older than available undo.
4、You want to recover data that is lost after a DDL operation modified the structure of tables. Using Flashback Table is not possible because a DDL was run on the tables between the desired point in time and the current time. Flashback Table cannot rewind tables through structural changes such as a truncate table operation.
译文:
1、您需要将非常少量的表恢复到特定的时间点。在这种情况下,TSPITR 不是最有效的解决方案,因为它将表空间中的所有对象都移动到指定的时间点。
2、您需要恢复已被逻辑损坏或已被删除和清除的表。
3、Flashback Table 不可用,如undo 数据已经被覆盖。
4、恢复在DDL操作修改表结构之后丢失的数据。使用Flashback表是不可能的,因为在需要的时间点和当前时间之间的表上运行一个DDL。闪回表不能通过诸如截断表操作之类的结构更改来倒表。
RMAN的表级和表分区级恢复限制:
1、Tables and table partitions belonging to SYS schema cannot be recovered.
2、Tables and table partitions from SYSTEM and SYSAUX tablespaces cannot be recovered.
3、Tables and table partitions on standby databases cannot be recovered.
4、Tables with named NOT NULL constraints cannot be recovered with the REMAP option.
RMAN的表级和表分区级恢复前提:
1、The target database must be in read-write mode.
2、The target database must be in ARCHIVELOG mode.
3、You must have RMAN backups of the tables or table partitions as they existed at the point in time to which you want recover these objects.
4、To recover single table partitions, the COMPATIBLE initialization parameter for target database must be set to 11.1.0 or higher.
恢复方法:
1、SCN
2、Time
3、Sequence number
RMAN从备份中自动处理恢复表或者表分区时的步骤:
1、Determines which backup contains the tables or table partitions that need to be recovered, based on the point in time specified for the recovery.
2、Determines if there is sufficient space on the target host to create the auxiliary instance that will be used during the table or partition recovery process.
If the required space is not available, then RMAN displays an error and exits the recovery operation.
3、Creates an auxiliary database and recovers the specified tables or table partitions, until the specified point in time, into this auxiliary database.
You can specify the location to which the recovered data files are stored in the auxiliary database.
4、Creates a Data Pump export dump file that contains the recovered tables or table partitions.
You can specify the name and the location of the export dump file used to store the metadata of the recovered tables or table partitions.
5、(Optional) Imports the Data Pump export dump file into the target instance.
You can choose not to import the export dump file that contains the recovered tables or table partitions into the target database. If you do not import the export dump file as part of the recovery process, you must manually import it later using the Data Pump Import utility.
6、(Optional) Renames the recovered tables or table partitions in the target database.
You can also import recovered objects into a tablespace or schema that is different from the one in which they originally existed.
译:
1.确定哪些备份包含需要恢复的表或表分区,根据指定的时间来进行恢复。
2.确定目标主机上是否有足够的空间来创建将在表或分区恢复过程中使用的辅助实例。 如果需要的空间不足,那么RMAN会报错并退出恢复操作。
3.创建一个辅助数据库并恢复指定的表或表分区,并根据指定的时间来恢复指定的表或表分区到辅助数据库中。 可以指定用于存储已恢复表或表分区的元数据的导出转储文件的名称和位置。
4.创建一个数据泵导出转储文件,其中包含已恢复的表或表分区。可以指定用于存储已恢复表或表分区的元数据的导出转储文件的名称和位置。
5. (可选操作)将上一步生产的数据泵文件导入到目标实例中。您可以选择不导入包含已恢复的表或表分区到目标数据库的导出转储文件。如果您不导入导出转储文件作为恢复过程的一部分,那么您必须在稍后使用 impdp 手工导入。
6. (可选操作)在目标数据库中rename 恢复表或表分区。
PDB操作流程:
-- 准备测试环境
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> select log_mode from v$database;
LOG_MODE
------------
ARCHIVELOG
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB01 READ WRITE NO
4 PDB02 READ WRITE NO
SQL> alter session set container=pdb01;
Session altered.
SQL> select tablespace_name from dba_tablespaces;
TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USERS
BBB
6 rows selected.
-- 建立测试用户
SQL> show con_name
CON_NAME
------------------------------
PDB01
SQL> create user andy identified by andy default tablespace bbb;
User created.
SQL> grant dba to andy;
Grant succeeded.
-- 创建测试表:
SQL> conn andy/andy@10.219.24.16:1521/pdb01
Connected.
SQL> create table andy(id int);
Table created.
SQL> insert into andy values(1);
1 row created.
SQL> commit;
Commit complete.
SQL> conn / as sysdba
Connected.
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
-- RMAN 备份CDB
--使用如下命令备份CDB的组建:ROOT,SEED,PDBS:
[oracle@12c ~]$ rman target /
RMAN> backup database plus archivelog;
Finished Control File and SPFILE Autobackup at 21-MAY-17
说明: 关于 Oracle 12c 多租户 CDB 与 PDB 备份 请参考 ->http://blog.csdn.net/zhang123456456/article/details/71540927
-- 恢复数据
drop andy purge 表,然后执行恢复操作:
SQL> conn andy/andy@10.219.24.16:1521/pdb01
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
2088202
SQL> drop table andy purge;
Table dropped.
SQL> select * from andy;
ERROR at line 1:
ORA-00942: table or view does not exist
-- 创建辅助目录
[oracle@12c ~]$ mkdir -p /tmp/oracle/recover
[oracle@12c ~]$ mkdir -p /tmp/recover/dumpfiles
-- 恢复时,cdb 与 pdb 都是Open read writer 状态。
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB01 READ WRITE NO
4 PDB02 READ WRITE NO
-- 恢复命令
[oracle@12c ~]$ rman target /
RMAN>
run{
RECOVER TABLE andy.andy of pluggable database pdb01
UNTIL SCN 2088202
AUXILIARY DESTINATION '/home/oracle/tmp/oracle/recover'
datapump destination '/home/oracle/tmp/recover/dumpfiles';
}
补充:恢复表不支持公共用户,开始作者使用的是公共用户做实验,报错如下,也没有很明显的提示,后换本地用户没有这类报错。
RMAN>recover table c##andy.andy_recover_t of pluggable database pdb01
until scn 2060046
auxiliary destination '/home/oracle/tmp/oracle/recover'
datapump destination '/home/oracle/tmp/recover/dumpfiles';
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "datapump": expecting one of: "advise, allocate, alter, analyze, associate statistics, audit, backup, begin, @, call, catalog, change, comment, commit, configure, connect, convert, copy, create, create catalog, create global, create script, create virtual, crosscheck, declare, delete, delete from, describe, describe catalog, disassociate statistics, drop, drop catalog, drop database, duplicate, exit, explain plan, flashback, flashback table, grant, grant catalog, grant register, host, import, insert, list, lock, merge, mount, noaudit, open, print, purge, quit, recover, register, release, rename, repair, replace, report, "
RMAN-01007: at line 1 column 1 file: standard input
-- 恢复查看
SQL> select * from andy;
ID
----------
1 >恢复成功
恢复过程:还原system,undo,sysaux表空间,然后read only数据库,然后重启数据库还原表所在表空间,然后expdp导出表,根据需要决定是否导入表到原PDB数据库中,最后删除辅助数据库。 整个过程对原PDB没有影响。
补充:恢复过程监控
[oracle@12c dumpfiles]$ cd /home/oracle/tmp/oracle/recover
[oracle@12c recover]$ ll
total 8
drwxr-x---. 6 oracle oinstall 4096 May 21 18:26 ANDYCDB
drwxr-x---. 4 oracle oinstall 4096 May 21 18:35 PCAS_PITR_PDB01_ANDYCDB
[oracle@12c recover]$ cd /home/oracle/tmp/recover/dumpfiles
[oracle@12c dumpfiles]$ ll
total 164
-rw-r-----. 1 oracle oinstall 167936 May 21 19:12 tspitr_fgxA_79856.dmp
[root@12c ~]# ps -ef|grep smon
oracle 3838 1 0 17:45 ? 00:00:00 ora_smon_andycdb
oracle 5769 1 0 18:58 ? 00:00:00 ora_smon_fgxA
root 5941 3772 0 19:03 pts/3 00:00:00 grep smon
说明:辅助实例有启动实例进程fgxA
恢复过程日志如下:
RMAN> run{
RECOVER TABLE andy.andy of pluggable database pdb01
UNTIL SCN 2088202
AUXILIARY DESTINATION '/home/oracle/tmp/oracle/recover'
datapump destination '/home/oracle/tmp/recover/dumpfiles';
}2> 3> 4> 5> 6>
Starting recover at 21-MAY-17
using channel ORA_DISK_1
RMAN-05026: warning: presuming following set of tablespaces applies to specified point-in-time
List of tablespaces expected to have UNDO segments
Tablespace SYSTEM
Tablespace PDB01:SYSTEM
Tablespace UNDOTBS1
Tablespace PDB01:UNDOTBS1
Creating automatic instance, with SID='fgxA'
initialization parameters used for automatic instance:
db_name=ANDYCDB
db_unique_name=fgxA_pitr_pdb01_ANDYCDB
compatible=12.2.0
db_block_size=8192
db_files=200
diagnostic_dest=/home/oracle/app/oracle
_system_trig_enabled=FALSE
sga_target=692M
processes=200
db_create_file_dest=/home/oracle/tmp/oracle/recover
log_archive_dest_1='location=/home/oracle/tmp/oracle/recover'
enable_pluggable_database=true
_clone_one_pdb_recovery=true
max_string_size=EXTENDED
#No auxiliary parameter file used
starting up automatic instance ANDYCDB
Oracle instance started
Total System Global Area 725614592 bytes
Fixed Size 8797008 bytes
Variable Size 205522096 bytes
Database Buffers 507510784 bytes
Redo Buffers 3784704 bytes
Automatic instance created
contents of Memory Script:
{
# set requested point in time
set until scn 2088202;
# 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';
}
executing Memory Script
executing command: SET until clause
Staring restore at 21-MAY-17
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=35 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 /home/oracle/app/oracle/product/12.2.0/dbhome_1/dbs/c-4182839949-20170521-00
channel ORA_AUX_DISK_1: piece handle=/home/oracle/app/oracle/product/12.2.0/dbhome_1/dbs/c-4182839949-20170521-00 tag=TAG20170521T041813
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/home/oracle/tmp/oracle/recover/ANDYCDB/controlfile/o1_mf_dl2wpytg_.ctl
Finished restore at 21-MAY-17
sql statement: alter database mount clone database
sql statement: alter system archive log current
contents of Memory Script:
{
# set requested point in time
set until scn 2088202;
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile 1 to new;
set newname for clone datafile 9 to new;
set newname for clone datafile 4 to new;
set newname for clone datafile 11 to new;
set newname for clone datafile 3 to new;
set newname for clone datafile 10 to new;
set newname for clone tempfile 1 to new;
set newname for clone tempfile 3 to new;
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 1, 9, 4, 11, 3, 10;
switch clone datafile all;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
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/tmp/oracle/recover/ANDYCDB/datafile/o1_mf_temp_%u_.tmp in control file
renamed tempfile 3 to /home/oracle/tmp/oracle/recover/ANDYCDB/4F44590EB7B74390E0531018DB0A1976/datafile/o1_mf_temp_%u_.tmp in control file
Starting restore at 21-MAY-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/tmp/oracle/recover/ANDYCDB/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /home/oracle/tmp/oracle/recover/ANDYCDB/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /home/oracle/tmp/oracle/recover/ANDYCDB/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /home/oracle/app/oracle/product/12.2.0/dbhome_1/dbs/0ss4p2c8_1_1
channel ORA_AUX_DISK_1: piece handle=/home/oracle/app/oracle/product/12.2.0/dbhome_1/dbs/0ss4p2c8_1_1 tag=TAG20170521T041359
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:38
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 00009 to /home/oracle/tmp/oracle/recover/ANDYCDB/4F44590EB7B74390E0531018DB0A1976/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00011 to /home/oracle/tmp/oracle/recover/ANDYCDB/4F44590EB7B74390E0531018DB0A1976/datafile/o1_mf_undotbs1_%u_.dbf
/ANDYCDB/4F44590EB7B74390E0531018DB0A1976/datafile/o1_mf_sysaux_%u_.dbf
2.2.0/dbhome_1/dbs/0ts4p2eu_1_1
1/dbs/0ts4p2eu_1_1 tag=TAG20170521T041359
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:58
Finished restore at 21-MAY-17
datafile 1 switched to datafile copy
ver/ANDYCDB/datafile/o1_mf_system_dl2wqg9o_.dbf
datafile 9 switched to datafile copy
ver/ANDYCDB/4F44590EB7B74390E0531018DB0A1976/datafile/o1_mf_system_dl2wtl6g_.dbf
datafile 4 switched to datafile copy
ver/ANDYCDB/datafile/o1_mf_undotbs1_dl2wqgcc_.dbf
datafile 11 switched to datafile copy
ver/ANDYCDB/4F44590EB7B74390E0531018DB0A1976/datafile/o1_mf_undotbs1_dl2wtlf0_.dbf
datafile 3 switched to datafile copy
ver/ANDYCDB/datafile/o1_mf_sysaux_dl2wqgc0_.dbf
datafile 10 switched to datafile copy
ver/ANDYCDB/4F44590EB7B74390E0531018DB0A1976/datafile/o1_mf_sysaux_dl2wtl06_.db
contents of Memory Script:
{
# set requested point in time
set until scn 2088202;
# online the datafiles restored or switched
sql clone "alter database datafile 1 online";
sql clone 'PDB01' "alter database datafile
9 online";
sql clone "alter database datafile 4 online";
sql clone 'PDB01' "alter database datafile
11 online";
sql clone "alter database datafile 3 online";
sql clone 'PDB01' "alter database datafile
10 online";
# recover and open database read only
"UNDOTBS1", "SYSAUX", "PDB01":"SYSAUX";
sql clone 'alter database open read only';
}
executing Memory Script
executing command: SET until clause
sql statement: alter database datafile 1 online
sql statement: alter database datafile 9 online
sql statement: alter database datafile 4 online
sql statement: alter database datafile 11 online
sql statement: alter database datafile 3 online
sql statement: alter database datafile 10 online
Starting recover at 21-MAY-17
using channel ORA_AUX_DISK_1
starting media recovery
app/oracle/product/12.2.0/dbhome_1/dbs/arch1_20_943753232.dbf
app/oracle/product/12.2.0/dbhome_1/dbs/arch1_21_943753232.dbf
_943753232.dbf thread=1 sequence=20
_943753232.dbf thread=1 sequence=21
media recovery complete, elapsed time: 00:01:32
Finished recover at 21-MAY-17
sql statement: alter database open read only
contents of Memory Script:
{
sql clone 'alter pluggable database PDB01 open read only';
}
executing Memory Script
sql statement: alter pluggable database PDB01 open read only
contents of Memory Script:
{
sql clone "create spfile from memory";
shutdown clone immediate;
startup clone nomount;
sql clone "alter system set control_files =
nt=
''RMAN set'' scope=spfile";
shutdown clone immediate;
startup clone nomount;
# mount database
sql clone 'alter database mount clone database';
}
executing Memory Script
sql statement: create spfile from memory
database closed
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 725614592 bytes
Fixed Size 8797008 bytes
Variable Size 205522096 bytes
Database Buffers 507510784 bytes
Redo Buffers 3784704 bytes
r/ANDYCDB/controlfile/o1_mf_dl2wpytg_.ctl'' comment= ''RMAN set'' scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 725614592 bytes
Fixed Size 8797008 bytes
Variable Size 205522096 bytes
Database Buffers 507510784 bytes
Redo Buffers 3784704 bytes
sql statement: alter database mount clone database
contents of Memory Script:
{
# set requested point in time
set until scn 2088202;
# set destinations for recovery set and auxiliary set datafiles
set newname for datafile 13 to new;
set newname for datafile 14 to new;
set newname for datafile 15 to new;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 13, 14, 15;
switch clone datafile all;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 21-MAY-17
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=35 device type=DISK
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
f
f
f
2.2.0/dbhome_1/dbs/0ts4p2eu_1_1
1/dbs/0ts4p2eu_1_1 tag=TAG20170521T041359
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:16
Finished restore at 21-MAY-17
datafile 13 switched to datafile copy
x50h8_.dbf
datafile 14 switched to datafile copy
x50l4_.dbf
datafile 15 switched to datafile copy
x500q_.dbf
contents of Memory Script:
{
# set requested point in time
set until scn 2088202;
# online the datafiles restored or switched
sql clone 'PDB01' "alter database datafile
13 online";
sql clone 'PDB01' "alter database datafile
14 online";
sql clone 'PDB01' "alter database datafile
15 online";
# recover and open resetlogs
TBS1", "PDB01":"UNDOTBS1", "SYSAUX", "PDB01":"SYSAUX" delete archivelog;
alter clone database open resetlogs;
}
executing Memory Script
executing command: SET until clause
sql statement: alter database datafile 13 online
sql statement: alter database datafile 14 online
sql statement: alter database datafile 15 online
Starting recover at 21-MAY-17
using channel ORA_AUX_DISK_1
starting media recovery
app/oracle/product/12.2.0/dbhome_1/dbs/arch1_20_943753232.dbf
app/oracle/product/12.2.0/dbhome_1/dbs/arch1_21_943753232.dbf
_943753232.dbf thread=1 sequence=20
_943753232.dbf thread=1 sequence=21
media recovery complete, elapsed time: 00:00:18
Finished recover at 21-MAY-17
database opened
contents of Memory Script:
{
sql clone 'alter pluggable database PDB01 open';
}
executing Memory Script
sql statement: alter pluggable database PDB01 open
contents of Memory Script:
{
# create directory for datapump import
sql 'PDB01' "create or replace directory
TSPITR_DIROBJ_DPDIR as ''
/home/oracle/tmp/recover/dumpfiles''";
# create directory for datapump export
sql clone 'PDB01' "create or replace directory
TSPITR_DIROBJ_DPDIR as ''
/home/oracle/tmp/recover/dumpfiles''";
}
executing Memory Script
p/recover/dumpfiles''
p/recover/dumpfiles''
Performing export of tables...
EXPDP> Starting "SYS"."TSPITR_EXP_fgxA_Fvnl":
EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
rows
EXPDP> Master table "SYS"."TSPITR_EXP_fgxA_Fvnl" successfully loaded/unloaded
*****
EXPDP> Dump file set for SYS.TSPITR_EXP_fgxA_Fvnl is:
EXPDP> /home/oracle/tmp/recover/dumpfiles/tspitr_fgxA_79856.dmp
12:59 2017 elapsed 0 00:02:24
Export completed
contents of Memory Script:
{
# shutdown clone before import
shutdown clone abort
}
executing Memory Script
Oracle instance shut down
Performing import of tables...
IMPDP> Master table "SYS"."TSPITR_IMP_fgxA_txhb" successfully loaded/unloaded
IMPDP> Starting "SYS"."TSPITR_IMP_fgxA_txhb":
IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
rows
IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
16:32 2017 elapsed 0 00:01:06
Import completed
Removing automatic instance
Automatic instance removed
31018DB0A1976/datafile/o1_mf_temp_dl2x08jv_.tmp deleted
_dl2wzlwf_.tmp deleted
inelog/o1_mf_3_dl2x6vbp_.log deleted
inelog/o1_mf_2_dl2x6gt1_.log deleted
inelog/o1_mf_1_dl2x6gt1_.log deleted
4590EB7B74390E0531018DB0A1976/datafile/o1_mf_bbb_dl2x500q_.dbf deleted
4590EB7B74390E0531018DB0A1976/datafile/o1_mf_bbb_dl2x50l4_.dbf deleted
4590EB7B74390E0531018DB0A1976/datafile/o1_mf_bbb_dl2x50h8_.dbf deleted
31018DB0A1976/datafile/o1_mf_sysaux_dl2wtl06_.dbf deleted
ux_dl2wqgc0_.dbf deleted
31018DB0A1976/datafile/o1_mf_undotbs1_dl2wtlf0_.dbf deleted
tbs1_dl2wqgcc_.dbf deleted
31018DB0A1976/datafile/o1_mf_system_dl2wtl6g_.dbf deleted
em_dl2wqg9o_.dbf deleted
l2wpytg_.ctl deleted
auxiliary instance file tspitr_fgxA_79856.dmp deleted
Finished recover at 21-MAY-17
oracle@localhost:~$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.0.2 Beta on Mon Dec 24 01:46:37 2012
Copyright (c) 1982, 2012, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.0.2 – 64bit Beta
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 31
Current log sequence 33
SQL>
SQL>
SQL>
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 626327552 bytes
Fixed Size 2263520 bytes
Variable Size 469763616 bytes
Database Buffers 150994944 bytes
Redo Buffers 3305472 bytes
Database mounted.
SQL>
SQL>
SQL>
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
Database altered.
SQL> create user c##maclean identified by oracle;
User created.
SQL> grant dba to c##maclean;
Grant succeeded.
SQL>
SQL> conn c##maclean/oracle
Connected.
SQL>
SQL>
SQL>
SQL> create table recoverme as select * from dba_objects;
Table created.
SQL>
SQL> select current_scn from v$database;
CURRENT_SCN
———–
2164108
SQL>
SQL> select count(*) from recoverme;
COUNT(*)
———-
89112
SQL>
SQL> delete recoverme where rownum<2000;
1999 rows deleted.
SQL> commit;
Commit complete.
SQL> alter system checkpoint;
System altered.
oracle@localhost:~$ mkdir -p /tmp/oracle/recover
oracle@localhost:~$ mkdir -p /tmp/recover/dumpfiles
RECOVER TABLE “C##MACLEAN”.recoverme
UNTIL SCN 2164108
AUXILIARY DESTINATION ‘/tmp/oracle/recover’
DATAPUMP DESTINATION ‘/tmp/recover/dumpfiles’
DUMP FILE ‘recover.dat’
NOTABLEIMPORT;
ORA-29283: invalid file operation
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 12/24/2012 02:47:17
RMAN-06962: Error received during export of metadata
RMAN-06960: EXPDP> ORA-31626: job does not exist
ORA-31633: unable to create master table “SYSBACKUP.TSPITR_EXP_jjFw_trsu”
ORA-01552: cannot use system rollback segment for non-system tablespace ‘USERS’
RECOVER TABLE ‘C##MACLEAN’.’RECOVERME’
UNTIL SCN 2164108
AUXILIARY DESTINATION ‘/tmp/oracle/recover’
REMAP TABLE ‘C##MACLEAN’.’RECOVERME’:’RECOVERME1′;
SQL>
SQL> drop table recoverme;
Table dropped.
SQL> create table recoverme tablespace system as select * from dba_objects;
Table created.
SQL>
SQL>
SQL> select current_scn from v$database;
CURRENT_SCN
———–
2167801
SQL> select count(*) from recoverme;
COUNT(*)
———-
89113
SQL> delete recoverme where rownum<2000;
1999 rows deleted.
SQL> commit;
Commit complete.
SQL> alter system checkpoint;
System altered.
SQL> select count(*) from recoverme;
COUNT(*)
———-
87114
RECOVER TABLE “C##MACLEAN”.recoverme
UNTIL SCN 2167801
AUXILIARY DESTINATION ‘/tmp/oracle/recover’
DATAPUMP DESTINATION ‘/tmp/recover/dumpfiles’
DUMP FILE ‘recover.dat’
NOTABLEIMPORT;
connected to target database: CDB1 (DBID=762218087)
RMAN> RECOVER TABLE “C##MACLEAN”.recoverme
2> UNTIL SCN 2167801
3> AUXILIARY DESTINATION ‘/tmp/oracle/recover’
4> DATAPUMP DESTINATION ‘/tmp/recover/dumpfiles’
5> DUMP FILE ‘recover.dat’
6> NOTABLEIMPORT;
Starting recover at 24-DEC-12
using target database control file instead of recovery catalog
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=47 device type=DISK
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified Point-in-Time
List of tablespaces expected to have UNDO segments
Tablespace SYSTEM
Tablespace UNDOTBS1
Creating automatic instance, with SID=’BxCi’
initialization parameters used for automatic instance:
db_name=CDB1
db_unique_name=BxCi_pitr_CDB1
compatible=12.0.0.0.0
db_block_size=8192
db_files=200
sga_target=1G
processes=80
db_create_file_dest=/tmp/oracle/recover
log_archive_dest_1=’location=/tmp/oracle/recover’
_enable_pluggable_database=true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used
starting up automatic instance CDB1
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2268624 bytes
Variable Size 281018928 bytes
Database Buffers 780140544 bytes
Redo Buffers 5509120 bytes
Automatic instance created
contents of Memory Script:
{
# set requested point in time
set until scn 2167801;
# 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’;
}
executing Memory Script
executing command: SET until clause
Starting restore at 24-DEC-12
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=19 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/app/oracle/fast_recovery_area/CDB1/backupset/2012_12_24/o1_mf_ncsnf_TAG20121224T021238_8fhgvdp5_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/CDB1/backupset/2012_12_24/o1_mf_ncsnf_TAG20121224T021238_8fhgvdp5_.bkp tag=TAG20121224T021238
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/tmp/oracle/recover/CDB1/controlfile/o1_mf_8fhlgy7g_.ctl
Finished restore at 24-DEC-12
sql statement: alter database mount clone database
sql statement: alter system archive log current
contents of Memory Script:
{
# set requested point in time
set until scn 2167801;
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile 1 to new;
set newname for clone datafile 4 to new;
set newname for clone datafile 3 to new;
set newname for clone tempfile 1 to new;
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 1, 4, 3;
switch clone datafile all;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
renamed tempfile 1 to /tmp/oracle/recover/CDB1/datafile/o1_mf_temp_%u_.tmp in control file
Starting restore at 24-DEC-12
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 /tmp/oracle/recover/CDB1/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /tmp/oracle/recover/CDB1/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /tmp/oracle/recover/CDB1/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/CDB1/backupset/2012_12_24/o1_mf_nnndf_TAG20121224T021238_8fhgjqd3_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/CDB1/backupset/2012_12_24/o1_mf_nnndf_TAG20121224T021238_8fhgjqd3_.bkp tag=TAG20121224T021238
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:02:35
Finished restore at 24-DEC-12
datafile 1 switched to datafile copy
input datafile copy RECID=4 STAMP=802840959 file name=/tmp/oracle/recover/CDB1/datafile/o1_mf_system_8fhlh4w6_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=5 STAMP=802840959 file name=/tmp/oracle/recover/CDB1/datafile/o1_mf_undotbs1_8fhlk5y4_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=6 STAMP=802840959 file name=/tmp/oracle/recover/CDB1/datafile/o1_mf_sysaux_8fhlh4w8_.dbf
contents of Memory Script:
{
# set requested point in time
set until scn 2167801;
# online the datafiles restored or switched
sql clone “alter database datafile 1 online”;
sql clone “alter database datafile 4 online”;
sql clone “alter database datafile 3 online”;
# recover and open database read only
recover clone database tablespace “SYSTEM”, “UNDOTBS1”, “SYSAUX”;
sql clone ‘alter database open read only’;
}
executing Memory Script
executing command: SET until clause
sql statement: alter database datafile 1 online
sql statement: alter database datafile 4 online
sql statement: alter database datafile 3 online
Starting recover at 24-DEC-12
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 34 is already on disk as file /u01/app/oracle/fast_recovery_area/CDB1/archivelog/2012_12_24/o1_mf_1_34_8fhgvg5r_.arc
archived log for thread 1 with sequence 35 is already on disk as file /u01/app/oracle/fast_recovery_area/CDB1/archivelog/2012_12_24/o1_mf_1_35_8fhhpg2f_.arc
archived log for thread 1 with sequence 36 is already on disk as file /u01/app/oracle/fast_recovery_area/CDB1/archivelog/2012_12_24/o1_mf_1_36_8fhhr5oz_.arc
archived log for thread 1 with sequence 37 is already on disk as file /u01/app/oracle/fast_recovery_area/CDB1/archivelog/2012_12_24/o1_mf_1_37_8fhj8nbh_.arc
archived log for thread 1 with sequence 38 is already on disk as file /u01/app/oracle/fast_recovery_area/CDB1/archivelog/2012_12_24/o1_mf_1_38_8fhk741v_.arc
archived log for thread 1 with sequence 39 is already on disk as file /u01/app/oracle/fast_recovery_area/CDB1/archivelog/2012_12_24/o1_mf_1_39_8fhlgnor_.arc
archived log file name=/u01/app/oracle/fast_recovery_area/CDB1/archivelog/2012_12_24/o1_mf_1_34_8fhgvg5r_.arc thread=1 sequence=34
archived log file name=/u01/app/oracle/fast_recovery_area/CDB1/archivelog/2012_12_24/o1_mf_1_35_8fhhpg2f_.arc thread=1 sequence=35
archived log file name=/u01/app/oracle/fast_recovery_area/CDB1/archivelog/2012_12_24/o1_mf_1_36_8fhhr5oz_.arc thread=1 sequence=36
archived log file name=/u01/app/oracle/fast_recovery_area/CDB1/archivelog/2012_12_24/o1_mf_1_37_8fhj8nbh_.arc thread=1 sequence=37
archived log file name=/u01/app/oracle/fast_recovery_area/CDB1/archivelog/2012_12_24/o1_mf_1_38_8fhk741v_.arc thread=1 sequence=38
archived log file name=/u01/app/oracle/fast_recovery_area/CDB1/archivelog/2012_12_24/o1_mf_1_39_8fhlgnor_.arc thread=1 sequence=39
media recovery complete, elapsed time: 00:00:11
Finished recover at 24-DEC-12
sql statement: alter database open read only
Removing automatic instance
shutting down automatic instance
Oracle instance shut down
Automatic instance removed
auxiliary instance file /tmp/oracle/recover/CDB1/datafile/o1_mf_sysaux_8fhlh4w8_.dbf deleted
auxiliary instance file /tmp/oracle/recover/CDB1/datafile/o1_mf_undotbs1_8fhlk5y4_.dbf deleted
auxiliary instance file /tmp/oracle/recover/CDB1/datafile/o1_mf_system_8fhlh4w6_.dbf deleted
auxiliary instance file /tmp/oracle/recover/CDB1/datafile/o1_mf_sysaux_8fhlh4w8_.dbf deleted
auxiliary instance file /tmp/oracle/recover/CDB1/datafile/o1_mf_undotbs1_8fhlk5y4_.dbf deleted
auxiliary instance file /tmp/oracle/recover/CDB1/datafile/o1_mf_system_8fhlh4w6_.dbf deleted
auxiliary instance file /tmp/oracle/recover/CDB1/controlfile/o1_mf_8fhlgy7g_.ctl deleted
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 12/24/2012 03:23:04
RMAN-05063: Cannot recover specified tables
RMAN-05059: Table C##MACLEAN.RECOVERME resides in tablespace SYSTEM
RMAN-05003: Tablespace Point-in-Time Recovery is not allowed for tablespace SYSTEM
RECOVER TABLE “C##MACLEAN”.recoverme
UNTIL SCN 2164108
AUXILIARY DESTINATION ‘/tmp/oracle/recover’
DATAPUMP DESTINATION ‘/tmp/recover/dumpfiles’
DUMP FILE ‘recover.dat’
NOTABLEIMPORT;
需要明确使用SYS登录才能成功
oracle@localhost:~$ rman target sys/oracle
Recovery Manager: Release 12.1.0.0.2 – Beta on Mon Dec 24 07:41:36 2012
Copyright (c) 1982, 2012, Oracle and/or its affiliates. All rights reserved.
connected to target database: CDB1 (DBID=762218087)
RMAN> RECOVER TABLE “C##MACLEAN”.recoverme
2> UNTIL SCN 2164108
3> AUXILIARY DESTINATION ‘/tmp/oracle/recover’
4> DATAPUMP DESTINATION ‘/tmp/recover/dumpfiles’
5> DUMP FILE ‘recover.dat’
6> NOTABLEIMPORT;
Starting recover at 24-DEC-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=40 device type=DISK
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified Point-in-Time
List of tablespaces expected to have UNDO segments
Tablespace SYSTEM
Tablespace UNDOTBS1
Creating automatic instance, with SID=’npaw’
initialization parameters used for automatic instance:
db_name=CDB1
db_unique_name=npaw_pitr_CDB1
compatible=12.0.0.0.0
db_block_size=8192
db_files=200
sga_target=1G
processes=80
db_create_file_dest=/tmp/oracle/recover
log_archive_dest_1=’location=/tmp/oracle/recover’
_enable_pluggable_database=true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used
starting up automatic instance CDB1
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2268624 bytes
Variable Size 281018928 bytes
Database Buffers 780140544 bytes
Redo Buffers 5509120 bytes
Automatic instance created
contents of Memory Script:
{
# set requested point in time
set until scn 2164108;
# 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’;
}
executing Memory Script
executing command: SET until clause
Starting restore at 24-DEC-12
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=19 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/app/oracle/fast_recovery_area/CDB1/backupset/2012_12_24/o1_mf_ncsnf_TAG20121224T021238_8fhgvdp5_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/CDB1/backupset/2012_12_24/o1_mf_ncsnf_TAG20121224T021238_8fhgvdp5_.bkp tag=TAG20121224T021238
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/tmp/oracle/recover/CDB1/controlfile/o1_mf_8fj1t7s0_.ctl
Finished restore at 24-DEC-12
sql statement: alter database mount clone database
sql statement: alter system archive log current
contents of Memory Script:
{
# set requested point in time
set until scn 2164108;
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile 1 to new;
set newname for clone datafile 4 to new;
set newname for clone datafile 3 to new;
set newname for clone tempfile 1 to new;
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 1, 4, 3;
switch clone datafile all;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
renamed tempfile 1 to /tmp/oracle/recover/CDB1/datafile/o1_mf_temp_%u_.tmp in control file
Starting restore at 24-DEC-12
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 /tmp/oracle/recover/CDB1/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /tmp/oracle/recover/CDB1/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /tmp/oracle/recover/CDB1/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/CDB1/backupset/2012_12_24/o1_mf_nnndf_TAG20121224T021238_8fhgjqd3_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/CDB1/backupset/2012_12_24/o1_mf_nnndf_TAG20121224T021238_8fhgjqd3_.bkp tag=TAG20121224T021238
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:02:25
Finished restore at 24-DEC-12
datafile 1 switched to datafile copy
input datafile copy RECID=4 STAMP=802856672 file name=/tmp/oracle/recover/CDB1/datafile/o1_mf_system_8fj1thhh_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=5 STAMP=802856672 file name=/tmp/oracle/recover/CDB1/datafile/o1_mf_undotbs1_8fj1w5c5_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=6 STAMP=802856672 file name=/tmp/oracle/recover/CDB1/datafile/o1_mf_sysaux_8fj1thhj_.dbf
contents of Memory Script:
{
# set requested point in time
set until scn 2164108;
# online the datafiles restored or switched
sql clone “alter database datafile 1 online”;
sql clone “alter database datafile 4 online”;
sql clone “alter database datafile 3 online”;
# recover and open database read only
recover clone database tablespace “SYSTEM”, “UNDOTBS1”, “SYSAUX”;
sql clone ‘alter database open read only’;
}
executing Memory Script
executing command: SET until clause
sql statement: alter database datafile 1 online
sql statement: alter database datafile 4 online
sql statement: alter database datafile 3 online
Starting recover at 24-DEC-12
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 34 is already on disk as file /u01/app/oracle/fast_recovery_area/CDB1/archivelog/2012_12_24/o1_mf_1_34_8fhgvg5r_.arc
archived log for thread 1 with sequence 35 is already on disk as file /u01/app/oracle/fast_recovery_area/CDB1/archivelog/2012_12_24/o1_mf_1_35_8fhhpg2f_.arc
archived log file name=/u01/app/oracle/fast_recovery_area/CDB1/archivelog/2012_12_24/o1_mf_1_34_8fhgvg5r_.arc thread=1 sequence=34
archived log file name=/u01/app/oracle/fast_recovery_area/CDB1/archivelog/2012_12_24/o1_mf_1_35_8fhhpg2f_.arc thread=1 sequence=35
media recovery complete, elapsed time: 00:00:03
Finished recover at 24-DEC-12
sql statement: alter database open read only
contents of Memory Script:
{
sql clone “create spfile from memory”;
shutdown clone immediate;
startup clone nomount;
sql clone “alter system set control_files =
”/tmp/oracle/recover/CDB1/controlfile/o1_mf_8fj1t7s0_.ctl” comment=
”RMAN set” scope=spfile”;
shutdown clone immediate;
startup clone nomount;
# mount database
sql clone ‘alter database mount clone database’;
}
executing Memory Script
sql statement: create spfile from memory
database closed
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2268624 bytes
Variable Size 285213232 bytes
Database Buffers 775946240 bytes
Redo Buffers 5509120 bytes
sql statement: alter system set control_files = ”/tmp/oracle/recover/CDB1/controlfile/o1_mf_8fj1t7s0_.ctl” comment= ”RMAN set” scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2268624 bytes
Variable Size 285213232 bytes
Database Buffers 775946240 bytes
Redo Buffers 5509120 bytes
sql statement: alter database mount clone database
contents of Memory Script:
{
# set requested point in time
set until scn 2164108;
# set destinations for recovery set and auxiliary set datafiles
set newname for datafile 6 to new;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 6;
switch clone datafile all;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
Starting restore at 24-DEC-12
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=18 device type=DISK
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 00006 to /tmp/oracle/recover/NPAW_PITR_CDB1/datafile/o1_mf_users_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/CDB1/backupset/2012_12_24/o1_mf_nnndf_TAG20121224T021238_8fhgjqd3_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/CDB1/backupset/2012_12_24/o1_mf_nnndf_TAG20121224T021238_8fhgjqd3_.bkp tag=TAG20121224T021238
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:55
Finished restore at 24-DEC-12
datafile 6 switched to datafile copy
input datafile copy RECID=8 STAMP=802856763 file name=/tmp/oracle/recover/NPAW_PITR_CDB1/datafile/o1_mf_users_8fj21sqp_.dbf
contents of Memory Script:
{
# set requested point in time
set until scn 2164108;
# online the datafiles restored or switched
sql clone “alter database datafile 6 online”;
# recover and open resetlogs
recover clone database tablespace “USERS”, “SYSTEM”, “UNDOTBS1”, “SYSAUX” delete archivelog;
alter clone database open resetlogs;
}
executing Memory Script
executing command: SET until clause
sql statement: alter database datafile 6 online
Starting recover at 24-DEC-12
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 34 is already on disk as file /u01/app/oracle/fast_recovery_area/CDB1/archivelog/2012_12_24/o1_mf_1_34_8fhgvg5r_.arc
archived log for thread 1 with sequence 35 is already on disk as file /u01/app/oracle/fast_recovery_area/CDB1/archivelog/2012_12_24/o1_mf_1_35_8fhhpg2f_.arc
archived log file name=/u01/app/oracle/fast_recovery_area/CDB1/archivelog/2012_12_24/o1_mf_1_34_8fhgvg5r_.arc thread=1 sequence=34
archived log file name=/u01/app/oracle/fast_recovery_area/CDB1/archivelog/2012_12_24/o1_mf_1_35_8fhhpg2f_.arc thread=1 sequence=35
media recovery complete, elapsed time: 00:00:01
Finished recover at 24-DEC-12
database opened
contents of Memory Script:
{
# create directory for datapump import
sql “create or replace directory TSPITR_DIROBJ_DPDIR as ”
/tmp/recover/dumpfiles””;
# create directory for datapump export
sql clone “create or replace directory TSPITR_DIROBJ_DPDIR as ”
/tmp/recover/dumpfiles””;
}
executing Memory Script
sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ”/tmp/recover/dumpfiles”
sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ”/tmp/recover/dumpfiles”
Performing export of tables…
EXPDP> Starting “SYS”.”TSPITR_EXP_npaw_sAzh”:
EXPDP> Estimate in progress using BLOCKS method…
EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
EXPDP> Total estimation using BLOCKS method: 12 MB
EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
EXPDP> . . exported “C##MACLEAN”.”RECOVERME” 9.946 MB 89112 rows
EXPDP> Master table “SYS”.”TSPITR_EXP_npaw_sAzh” successfully loaded/unloaded
EXPDP> ******************************************************************************
EXPDP> Dump file set for SYS.TSPITR_EXP_npaw_sAzh is:
EXPDP> /tmp/recover/dumpfiles/recover.dat
EXPDP> Job “SYS”.”TSPITR_EXP_npaw_sAzh” successfully completed at Mon Dec 24 07:47:08 2012 elapsed 0 00:00:23
Export completed
Not performing table import after point-in-time recovery
Removing automatic instance
shutting down automatic instance
Oracle instance shut down
Automatic instance removed
auxiliary instance file /tmp/oracle/recover/CDB1/datafile/o1_mf_temp_8fj1z8p6_.tmp deleted
auxiliary instance file /tmp/oracle/recover/NPAW_PITR_CDB1/onlinelog/o1_mf_3_8fj220tk_.log deleted
auxiliary instance file /tmp/oracle/recover/NPAW_PITR_CDB1/onlinelog/o1_mf_2_8fj21zo9_.log deleted
auxiliary instance file /tmp/oracle/recover/NPAW_PITR_CDB1/onlinelog/o1_mf_1_8fj21y5n_.log deleted
auxiliary instance file /tmp/oracle/recover/NPAW_PITR_CDB1/datafile/o1_mf_users_8fj21sqp_.dbf deleted
auxiliary instance file /tmp/oracle/recover/CDB1/datafile/o1_mf_sysaux_8fj1thhj_.dbf deleted
auxiliary instance file /tmp/oracle/recover/CDB1/datafile/o1_mf_undotbs1_8fj1w5c5_.dbf deleted
auxiliary instance file /tmp/oracle/recover/CDB1/datafile/o1_mf_system_8fj1thhh_.dbf deleted
auxiliary instance file /tmp/oracle/recover/CDB1/controlfile/o1_mf_8fj1t7s0_.ctl deleted
Finished recover at 24-DEC-12
SQL> create directory temp as ‘/tmp/recover/dumpfiles’;
Directory created.
SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.0.2 – 64bit Beta
With the Partitioning, OLAP, Data Mining and Real Application Testing options
oracle@localhost:~$ impdp system/oracle dumpfile=temp:recover.dat
Import: Release 12.1.0.0.2 – Beta on Mon Dec 24 07:51:28 2012
Copyright (c) 1982, 2012, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.0.2 – 64bit Beta
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table “SYSTEM”.”SYS_IMPORT_FULL_01″ successfully loaded/unloaded
Starting “SYSTEM”.”SYS_IMPORT_FULL_01″: system/******** dumpfile=temp:recover.dat
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported “C##MACLEAN”.”RECOVERME” 9.946 MB 89112 rows
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
Job “SYSTEM”.”SYS_IMPORT_FULL_01″ successfully completed at Mon Dec 24 07:51:38 2012 elapsed 0 00:00:09
SQL> select count(*) from “C##MACLEAN”.”RECOVERME” ;
COUNT(*)
———-
89112
About Me
.............................................................................................................................................
● 本文作者:小麦苗,部分内容整理自网络,若有侵权请联系小麦苗删除
● 本文在itpub( http://blog.itpub.net/26736162/abstract/1/ )、博客园( http://www.cnblogs.com/lhrbest )和个人weixin公众号( xiaomaimiaolhr )上有同步更新
● 本文itpub地址: http://blog.itpub.net/26736162/abstract/1/
● 本文博客园地址: http://www.cnblogs.com/lhrbest
● 本文pdf版、个人简介及小麦苗云盘地址: http://blog.itpub.net/26736162/viewspace-1624453/
● 数据库笔试面试题库及解答: http://blog.itpub.net/26736162/viewspace-2134706/
● DBA宝典今日头条号地址: http://www.toutiao.com/c/user/6401772890/#mid=1564638659405826
.............................................................................................................................................
● QQ群号: 230161599 (满) 、618766405
● weixin 群:可加我 weixin ,我拉大家进群,非诚勿扰
● 联系我请加QQ好友 ( 646634621 ) ,注明添加缘由
● 于 2018-04-01 06:00 ~ 2018-04-31 24:00 在魔都完成
● 最新修改时间:2018-04-01 06:00 ~ 2018-04-31 24:00
● 文章内容来源于小麦苗的学习笔记,部分整理自网络,若有侵权或不当之处还请谅解
● 版权所有,欢迎分享本文,转载请保留出处
.............................................................................................................................................
● 小麦苗的微店 : https://weidian.com/s/793741433?wfr=c&ifr=shopdetail
● 小麦苗出版的数据库类丛书 : http://blog.itpub.net/26736162/viewspace-2142121/
● 小麦苗OCP、OCM、高可用网络班 : http://blog.itpub.net/26736162/viewspace-2148098/
.............................................................................................................................................
使用 weixin 客户端 扫描下面的二维码来关注小麦苗的 weixin 公众号( xiaomaimiaolhr )及QQ群(DBA宝典), 学习最实用的数据库技术。
小麦苗的 weixin 公众号 小麦苗的DBA宝典QQ群2 《DBA笔试面试宝典》读者群 小麦苗的微店
.............................................................................................................................................
![]()
![]()
![]()
![]()
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26736162/viewspace-2152712/,如需转载,请注明出处,否则将追究法律责任。