ITPub博客

首页 > 数据库 > Oracle > 没有连接target database的情况下执行RMAN duplicate可能引发的问题

没有连接target database的情况下执行RMAN duplicate可能引发的问题

原创 Oracle 作者:oliseh 时间:2015-07-20 16:28:20 0 删除 编辑

前不久对某个数据库执行backup-based rman duplicate,duplicate过程中没有任何报错,但是duplicate完成后得到的副本数据库并没有包含我们所需要的数据。
下面是场景的重现:
假设T0时刻数据库A处于noarchivelog模式,生成了一个全备份;T0.5时刻打开数据库创建了t0720_1表,随即在T1时刻将数据库置为archivelog模式,之后生成了若干归档日志来到了T2时刻,我们要做的是在T3时刻通过rman duplicate生成一个数据库A在T0.5时刻的副本。T3>T2>T1>T0.5>T0
经过测试此种场景下获得的数据库A的副本是否是T0.5时刻的,取决于执行duplicate时是否连接target database,这里target database指的就是数据库A


环境版本:11.2.0.3.3


///////////

// 首先构造测试数据
///////////
###数据库A:从archivelog模式改成noarchivelog模式,生成consistent backup
shutdown immediate
startup mount
alter database noarchivelog;

SYS@tstdb1-SQL> archive log list
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     76
Current log sequence           78

rman target / catalog rman/773946@tstdb2

backup database include current controlfile format '/oradata06/dupuse/0720/whole_db_%u';

alter database open;

create table t1(id number) tablespace xdbts;
insert into t1 values(1);
commit;

SQL> select count(*) from t1;

  COUNT(*)
----------
         1
       
select sysdate from dual;
SYSDATE
-----------------
20150720 15:06:37          <---T0.5时刻是我们duplicate的目标时间,这个时间点上数据库是处于noarchivelog模式的,且t1表存在


---T0.5时刻:20150720 15:06:37所对应的修改日志都记录在log sequence# 78这个log里

SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     76
Current log sequence           78

###从noarchivelog修改成archivelog模式
shutdown immediate
startup mount
alter database archivelog;
alter database open;

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     76
Next log sequence to archive   78
Current log sequence           78

###切换一个logfile后当前log sequence#=79,也就是我们之后的dml操作都会记录在sequence#=79这个logfile里
alter system switch logfile;

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     77
Next log sequence to archive   79
Current log sequence           79

###创建测试表
create table t2(id number) tablespace XDBTS;
insert into t2 values(2);
commit;

SQL> select count(*) from t2;

  COUNT(*)
----------
         1
       
select sysdate from dual;
SYSDATE
-----------------
20150720 15:10:33

---切换一轮logfile
alter system switch logfile;
alter system switch logfile;
alter system switch logfile;

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     80
Next log sequence to archive   82
Current log sequence           82

---备份log sequence# 78~81
backup archivelog sequence between 78 and 81 format '/oradata06/dupuse/0720/arch_%u';

---log sequence 78~81的起始和结束时间,之后我们所指定的恢复时间20150720 15:06:37就包含在log sequence# 78里
RMAN> list backup of archivelog sequence between 78 and 81;

List of Backup Sets
===================

BS Key  Size       Device Type Elapsed Time Completion Time 
------- ---------- ----------- ------------ -----------------
111667  2.31M      DISK        00:00:00     20150720 15:11:56
        BP Key: 111670   Status: AVAILABLE  Compressed: NO  Tag: TAG20150720T151155
        Piece Name: /oradata06/dupuse/0720/arch_07qchcps

  List of Archived Logs in backup set 111667
  Thrd Seq     Low SCN    Low Time          Next SCN   Next Time
  ---- ------- ---------- ----------------- ---------- ---------
  1    78      12723364657858 20150720 14:35:41 12723364660676 20150720 15:08:51
  1    79      12723364660676 20150720 15:08:51 12723364660826 20150720 15:10:47
  1    80      12723364660826 20150720 15:10:47 12723364660831 20150720 15:10:54
  1    81      12723364660831 20150720 15:10:54 12723364660837 20150720 15:11:00

###复制backuppiece到duplicate命令的主机 
scp /oradata06/dupuse/0720/* oracle@10.10.149.110:/oradata06/dupuse/0720/

###duplicate instance所使用的初始化参数文件内容如下:
DB_NAME=dupdb3
sga_target=500M
db_block_size=8192
db_file_name_convert='/oradata06/testaaaaa','/oradata06/testccccc','/oradata06/omf/TSTDB1/datafile/o1_mf_omftbs1_1kkDQZdsn_.dbf','/oradata06/omf/9.dbf'
log_file_name_convert='/oradata06/testaaaaa','/oradata06/testccccc1'


###启动dupdb3到nomount

export ORACLE_SID=dupdb3
sqlplus '/as sysdba'
startup nomount

///////////
// 测试各种duplicate场景
///////////
 ###<场景1>:只连接target database,执行duplicate database tstdb1 to dupdb3 until time '20150720 15:06:37';
rman target sys/773946@tstdb1 auxiliary sys/asdf3_14@dupdb3

RMAN>duplicate database tstdb1 to dupdb3 until time '20150720 15:06:37';  <---20150720 15:06:37这个时间包含在log sequence# 78里,从duplicate的输出能看出apply log sequence# 78的过程,限于篇幅仅列出了部分输出
。。。
Starting restore at 20150720 15:16:43
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 /oradata06/testccccc/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /oradata06/testccccc/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /oradata06/testccccc/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /oradata06/testccccc/users01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00006 to /oradata06/testccccc/xdbts1.dbf
channel ORA_AUX_DISK_1: restoring datafile 00009 to /oradata06/omf/9.dbf
channel ORA_AUX_DISK_1: restoring datafile 00010 to /oradata06/testccccc/undotbs3.dbf
channel ORA_AUX_DISK_1: reading from backup piece /oradata06/dupuse/0720/whole_db_05qchccl
channel ORA_AUX_DISK_1: piece handle=/oradata06/dupuse/0720/whole_db_05qchccl tag=TAG20150720T150451
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:37
Finished restore at 20150720 15:17:21

contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=9 STAMP=885568988 file name=/oradata06/testccccc/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=10 STAMP=885568988 file name=/oradata06/testccccc/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=11 STAMP=885568988 file name=/oradata06/testccccc/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=12 STAMP=885568988 file name=/oradata06/testccccc/users01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=13 STAMP=885568988 file name=/oradata06/testccccc/xdbts1.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=14 STAMP=885568988 file name=/oradata06/omf/9.dbf
datafile 10 switched to datafile copy
input datafile copy RECID=15 STAMP=885568988 file name=/oradata06/testccccc/undotbs3.dbf

contents of Memory Script:
{
   set until time  "to_date('JUL 20 2015 15:06:37', 'MON DD YYYY HH24:MI:SS')";
   recover
   clone database
   skip forever tablespace  "TS0422_1"    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 20150720 15:17:22
using channel ORA_AUX_DISK_1

Executing: alter database datafile 5 offline drop
starting media recovery

channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=78
channel ORA_AUX_DISK_1: reading from backup piece /oradata06/dupuse/0720/arch_07qchcps
channel ORA_AUX_DISK_1: piece handle=/oradata06/dupuse/0720/arch_07qchcps tag=TAG20150720T151155
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/oracle/app/oracle/product/11.2.0/db_1/dbs/arch1_78_884446916.dbf thread=1 sequence=78      <---- apply log sequence# 78
channel clone_default: deleting archived log(s)
archived log file name=/oracle/app/oracle/product/11.2.0/db_1/dbs/arch1_78_884446916.dbf RECID=16 STAMP=885568991
media recovery complete, elapsed time: 00:00:01
Oracle instance started
。。。
Finished Duplicate Db at 20150720 15:17:56

---duplicate结束后连接到dupdb3、查看dupdb3库处于archivelog模式,但是数据库A在20150720 15:06:37 时刻尚处于noarchivelog模式,这一点稍有差异
export ORACLE_SID=dupdb3
sqlplus '/as sysdba'

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /oracle/app/oracle/product/11.2.0/db_1/dbs/arch
Oldest online log sequence     1
Next log sequence to archive   1
Current log sequence           1

---dupdb3库里的表对象检查,在20150720 15:06:37时刻表t1存在、表t2不存在,实际结果与此相符
SQL> select count(*) from t1;

  COUNT(*)
----------
         1

SQL> select count(*) from t0720_2;
select count(*) from t0720_2
                     *
ERROR at line 1:
ORA-00942: table or view does not exist


阶段结论
:在仅连接target database的情况下,duplicate的过程中能够apply archivelog,能准确生成数据库A在T0.5时刻的副本dupdb3;唯一有出入的是dupdb3变成了archivelog模式,而数据库A在T0.5时刻是noarchivelog模式的。猜测原因可能是因为没有连接catalog的情况下,controlfile作为repository无法记录修改历史,所以无法判断T0.5时刻数据库处于archivelog还是noarchivelog模式,统一以target database当前所处的状态为基准。

###<场景2.>duplicate仅连接catalog,执行duplicate database tstdb1 to dupdb3 until time '20150720 15:06:37';
rman catalog rman/773946@tstdb2 auxiliary sys/asdf3_14@dupdb3
RMAN> duplicate database tstdb1 dbid 2051793563 to dupdb3 until time '20150720 15:06:37';     <---为限制篇幅省略了部分输出
。。。
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 /oradata06/testccccc/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /oradata06/testccccc/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /oradata06/testccccc/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /oradata06/testccccc/users01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00006 to /oradata06/testccccc/xdbts1.dbf
channel ORA_AUX_DISK_1: restoring datafile 00009 to /oradata06/omf/9.dbf
channel ORA_AUX_DISK_1: restoring datafile 00010 to /oradata06/testccccc/undotbs3.dbf
channel ORA_AUX_DISK_1: reading from backup piece /oradata06/dupuse/0720/whole_db_05qchccl
channel ORA_AUX_DISK_1: piece handle=/oradata06/dupuse/0720/whole_db_05qchccl tag=TAG20150720T150451
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 20150720 15:24:24

contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=9 STAMP=885569410 file name=/oradata06/testccccc/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=10 STAMP=885569410 file name=/oradata06/testccccc/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=11 STAMP=885569410 file name=/oradata06/testccccc/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=12 STAMP=885569410 file name=/oradata06/testccccc/users01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=13 STAMP=885569410 file name=/oradata06/testccccc/xdbts1.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=14 STAMP=885569410 file name=/oradata06/omf/9.dbf
datafile 10 switched to datafile copy
input datafile copy RECID=15 STAMP=885569410 file name=/oradata06/testccccc/undotbs3.dbf

contents of Memory Script:
{
   set until time  "to_date('JUL 20 2015 15:06:37', 'MON DD YYYY HH24:MI:SS')";
   recover
   clone database
   skip forever tablespace  "TS0422_1"   noredo
    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 20150720 15:24:24
using channel ORA_AUX_DISK_1

Executing: alter database datafile 5 offline drop
Finished recover at 20150720 15:24:25
Oracle instance started
。。。
Finished Duplicate Db at 20150720 15:25:08

---duplicate结束以后查看dupdb3仍处于noarchivelog模式
export ORACLE_SID=dupdb3
sqlplus '/as sysdba'
SQL> archive log list
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            /oracle/app/oracle/product/11.2.0/db_1/dbs/arch
Oldest online log sequence     1
Current log sequence           1

---验证数据表t1、t2,结果t1、t2均不存在
SQL> select count(*) from t1;
select count(*) from t1
                     *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select count(*) from t2;
select count(*) from t2
                     *
ERROR at line 1:
ORA-00942: table or view does not exist


阶段结论: 仅连接catalog的情况下,观察到整个过程中没有apply archivelog的步骤,最后得到的dupdb仍处于noarchivelog模式;duplicate只能生成数据库A在T0时刻的副本dupdb3,不会apply任何含有大于等于T0时刻修改日志的archivelog,也就无法与恢复到我们所期望的T0.5时刻,duplicate得到的dupdb3处于noarchivelog模式。因为catalog能够准确记录每一次数据库状态的变更,当然也会记录noarchivelog->archivelog的状态变更,当我们指定duplicate database ... until time T0.5的时候RMAN判断此刻数据库A处于noarchivelog模式,也就不会去应用任何的archivelog。

###<场景3.>duplicate使用backup location,不连接target和catalog,执行duplicate database tstdb1 to dupdb3 until time '20150720 15:06:37' backup location '/oradata06/dupuse/0720/';
rman auxiliary sys/asdf3_14@dupdb3

RMAN> duplicate database tstdb1 to dupdb3 until time '20150720 15:06:37' backup location '/oradata06/dupuse/0720/';
。。。
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 /oradata06/testccccc/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /oradata06/testccccc/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /oradata06/testccccc/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /oradata06/testccccc/users01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00006 to /oradata06/testccccc/xdbts1.dbf
channel ORA_AUX_DISK_1: restoring datafile 00009 to /oradata06/omf/9.dbf
channel ORA_AUX_DISK_1: restoring datafile 00010 to /oradata06/testccccc/undotbs3.dbf
channel ORA_AUX_DISK_1: reading from backup piece /oradata06/dupuse/0720/whole_db_05qchccl
channel ORA_AUX_DISK_1: piece handle=/oradata06/dupuse/0720/whole_db_05qchccl tag=TAG20150720T150451
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 20150720 15:35:43

contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=8 STAMP=885570090 file name=/oradata06/testccccc/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=9 STAMP=885570090 file name=/oradata06/testccccc/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=10 STAMP=885570090 file name=/oradata06/testccccc/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=11 STAMP=885570090 file name=/oradata06/testccccc/users01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=12 STAMP=885570090 file name=/oradata06/testccccc/xdbts1.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=13 STAMP=885570090 file name=/oradata06/omf/9.dbf
datafile 10 switched to datafile copy
input datafile copy RECID=14 STAMP=885570090 file name=/oradata06/testccccc/undotbs3.dbf

contents of Memory Script:
{
   set until time  "to_date('JUL 20 2015 15:06:37', 'MON DD YYYY HH24:MI:SS')";
   recover
   clone database
   skip forever tablespace  "TS0422_1"   noredo
    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 20150720 15:35:44
using channel ORA_AUX_DISK_1

Executing: alter database datafile 5 offline drop
Finished recover at 20150720 15:35:44
Oracle instance started
。。。
Finished Duplicate Db at 20150720 15:36:13


---duplicate结束以后查看dupdb3仍处于noarchivelog模式

export ORACLE_SID=dupdb3
sqlplus '/as sysdba'
SQL> archive log list
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            /oracle/app/oracle/product/11.2.0/db_1/dbs/arch
Oldest online log sequence     1
Current log sequence           1

---验证数据表t1、t2,结果t1、t2均不存在
SQL> select count(*) from t1;
select count(*) from t1
                     *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select count(*) from t2;
select count(*) from t2
                     *
ERROR at line 1:
ORA-00942: table or view does not exist


阶段结论:在使用backup location的情况下,观察到整个过程中没有apply archivelog的步骤;duplicate只能生成数据库A在T0时刻的副本dupdb3,不会apply任何含有大于等于T0时刻修改记录的archivelog,也就无法与恢复到我们所期望的T0.5时刻,duplicate得到的dupdb3处于noarchivelog模式。因为catalog能够准确记录每一次数据库状态的变更,这也包括了会记录noarchivelog->archivelog的状态变更,当我们指定duplicate database ... until time T0.5的时候RMAN判断此刻数据库A处于noarchivelog模式,也就不会去应用任何的archivelog。

###<场景4.>duplicate同时连接target和catalog,执行duplicate database tstdb1 dbid 2051793563 to dupdb3 until time '20150720 15:06:37';

rman target sys/773946@tstdb1 catalog rman/773946@tstdb2 auxiliary sys/asdf3_14@dupdb3

RMAN> duplicate database tstdb1 dbid 2051793563 to dupdb3 until time '20150720 15:06:37';
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 /oradata06/testccccc/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /oradata06/testccccc/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /oradata06/testccccc/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /oradata06/testccccc/users01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00006 to /oradata06/testccccc/xdbts1.dbf
channel ORA_AUX_DISK_1: restoring datafile 00009 to /oradata06/omf/9.dbf
channel ORA_AUX_DISK_1: restoring datafile 00010 to /oradata06/testccccc/undotbs3.dbf
channel ORA_AUX_DISK_1: reading from backup piece /oradata06/dupuse/0720/whole_db_05qchccl
channel ORA_AUX_DISK_1: piece handle=/oradata06/dupuse/0720/whole_db_05qchccl tag=TAG20150720T150451
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 20150720 15:41:45

contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=9 STAMP=885570452 file name=/oradata06/testccccc/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=10 STAMP=885570452 file name=/oradata06/testccccc/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=11 STAMP=885570452 file name=/oradata06/testccccc/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=12 STAMP=885570452 file name=/oradata06/testccccc/users01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=13 STAMP=885570452 file name=/oradata06/testccccc/xdbts1.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=14 STAMP=885570452 file name=/oradata06/omf/9.dbf
datafile 10 switched to datafile copy
input datafile copy RECID=15 STAMP=885570452 file name=/oradata06/testccccc/undotbs3.dbf

contents of Memory Script:
{
   set until time  "to_date('JUL 20 2015 15:06:37', 'MON DD YYYY HH24:MI:SS')";
   recover
   clone database
   skip forever tablespace  "TS0422_1"    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 20150720 15:41:46
using channel ORA_AUX_DISK_1

Executing: alter database datafile 5 offline drop
starting media recovery

channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=78
channel ORA_AUX_DISK_1: reading from backup piece /oradata06/dupuse/0720/arch_07qchcps
channel ORA_AUX_DISK_1: piece handle=/oradata06/dupuse/0720/arch_07qchcps tag=TAG20150720T151155
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/oracle/app/oracle/product/11.2.0/db_1/dbs/arch1_78_884446916.dbf thread=1 sequence=78     <--- apply log sequence# 78
channel clone_default: deleting archived log(s)
archived log file name=/oracle/app/oracle/product/11.2.0/db_1/dbs/arch1_78_884446916.dbf RECID=16 STAMP=885570454
media recovery complete, elapsed time: 00:00:01
Finished recover at 20150720 15:41:49
Oracle instance started
。。。
Finished Duplicate Db at 20150720 15:42:34


---duplicate结束以后查看dupdb3变为了archivelog模式

export ORACLE_SID=dupdb3
sqlplus '/as sysdba'
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /oracle/app/oracle/product/11.2.0/db_1/dbs/arch
Oldest online log sequence     1
Next log sequence to archive   1
Current log sequence           1


---验证数据表t1、t2,结果t1、t2均不存在

SQL> select count(*) from t1;

  COUNT(*)
----------
         1

SQL> select count(*) from t2;
select count(*) from t2
                     *
ERROR at line 1:
ORA-00942: table or view does not exist

阶段结论: 同时连接target和catalog执行duplicate的情况下,duplicate能通过apply archivelog如期生成数据库A在T0.5时刻的副本dupdb3,唯一有出入的是dupdb3变成了archivelog模式,而数据库A在T0.5时刻是noarchivelog模式的。猜测原因可能是因为没有连接catalog的情况下,controlfile作为repository无法记录修改历史,所以无法判断T0.5时刻数据库处于archivelog还是noarchivelog模式,统一以target database当前所处的状态为基准。该测试结果同仅连接target的场景一致

总结:对一个archivelog模式的target数据库执行backup-based RMAN duplicate的时候,如果RMAN使用的是target数据库在noarchivelog模式下生成的一致性备份进行restore,那么会出现如下两种结果:
(1) 执行duplicate时如果连接了target,无论是否连接catalog,都能准确恢复到我们所指定的时间,但此时要注意复制出来的db是archivelog模式的,如果有必要需要人工将其改成noarchivelog模式
(2) 执行duplicate时如果没有连接target,只能恢复到一致性备份的时间点,这个时间点并不一定是我们所指定的时间,因此复制出来的db里不一定包含我们想要的数据。

不能确认是否为oracle的bug,建议大家尽可能在连接target database的情况下执行RMAN duplicate

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/53956/viewspace-1742178/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
不仅仅专注Oracle database技术, member of SHOUG

注册时间:2014-04-06

  • 博文量
    128
  • 访问量
    1616852