在sun t2000上兩臺主機間利用oracle10g rman_duplicate複製資料庫

wisdomone1發表於2009-11-29
1,duplicate db不同於standby db(dg)
2,要複製一個db,必須透過rman以nomount 連線到target(primary)db和auxiliary db
3,在auxilary db上開啟至少一個輔助通道(channel),複製工作主要透過輔助通道實行
4,為duplicate db生成一個新的dbid
5, 相同的dbid不能註冊在同一個recovery catalog db中,要註冊,須用dbnewid
6,duplicate db時,可以用rman skipp readonly or offline tablespace
SQL> select name,status,enabled from v$datafile;--status,enabled,

NAME
--------------------------------------------------------------------------------
STATUS  ENABLED
------- ----------
/oracle/oradata/ora10g/system01.dbf
SYSTEM  READ WRITE

/oracle/oradata/ora10g/undotbs01.dbf
ONLINE  READ WRITE

/oracle/oradata/ora10g/sysaux01.dbf
ONLINE  READ WRITE


NAME
--------------------------------------------------------------------------------
STATUS  ENABLED
------- ----------
/oracle/oradata/ora10g/users01.dbf
ONLINE  READ WRITE

+MIGRATION_DATA/ora10g/datafile/zxy.258.704104663
OFFLINE DISABLED


SQL>



實施duplicate過程 (此適用於oracle10g,兩機相同目錄結構,目錄是指data file,control file,tempfile,redo file)

1,構建一個用於輔助例項的密碼檔案
  在target db上面吧(hostname:capitek1)
  su - oracle
2,根據target db的spfile,建立出對應的pfile(用於duplicate上面的auxiliary instance spfile)
SQL> create pfile='/orainstall/target.ora' from spfile;

File created.


-bash-3.00$ vi target.ora
"target.ora" 29 行,1043 字元
dup.__db_cache_size=4160749568
dup.__java_pool_size=16777216
dup.__large_pool_size=16777216
dup.__shared_pool_size=872415232
dup.__streams_pool_size=0
*.audit_file_dest='/orainstall/admin/dup/adump'
*.background_dump_dest='/orainstall/admin/dup/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/orainstall/oradata/dup/control01.ctl','/orainstall/oradata/dup/control02.ctl','/orainstall/oradata/dup/cont
rol03.ctl'
*.core_dump_dest='/orainstall/admin/dup/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='dup'
*.db_recovery_file_dest='/orainstall/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=dupXDB)'
*.job_queue_processes=10
*.log_archive_format='%t_%s_%r.dbf'
*.nls_language='SIMPLIFIED CHINESE'
*.nls_territory='CHINA'
*.open_cursors=300
*.pga_aggregate_target=1693450240
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=5081399296
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/orainstall/admin/dup/udump'
control_files=('/orainstall/oradata/dup/control01.ctl','/orainstall/oradata/dup/control02.ctl','/orainstall/oradata/dup/cont
rol03.ctl')
db_file_name_convert=(/orainstall/oradata/target/,/orainstall/oradata/dup/)
log_file_name_convert=(/orainstall/oradata/target/,/orainstall/oradata/dup/)
~

3,根據target db的pfile建立對應的目錄
-bash-3.00$ mkdir -p /orainstall/admin/dup/adump
-bash-3.00$ mkdir -p /orainstall/admin/dup/bdump
-bash-3.00$ mkdir -p /orainstall/oradata/dup
-bash-3.00$ mkdir -p /orainstall/admin/dup/cdump
-bash-3.00$ mkdir -p /orainstall/flash_recovery_area
-bash-3.00$ mkdir -p /orainstall/admin/dup/udump
-bash-3.00$ cd $ORACLE_HOME
-bash-3.00$ pwd
/orainstall/oracle/product/10.2.0/db_1
-bash-3.00$ hostname
capitek2

4,以oracle身份在target和duplicate庫上面構建儲存rman備份的目錄
mkdir -p /orainstall/rmanbak


5,在target上面利用rman對庫進行一個全備
-bash-3.00$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Sun Nov 29 20:23:03 2009

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: TARGET (DBID=3106171664)

RMAN> backup as copy incremental level 0 database format '/orainstall/rmanbak/%Ubak' tag 'test duplicate db';

Starting backup at 29-NOV-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=151 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00001 name=/orainstall/oradata/target/system01.dbf
output filename=/orainstall/rmanbak/data_D-TARGET_I-3106171664_TS-SYSTEM_FNO-1_01kvjfvabak tag=TEST DUPLICATE DB recid=1 stamp=704233466
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile fno=00003 name=/orainstall/oradata/target/sysaux01.dbf
output filename=/orainstall/rmanbak/data_D-TARGET_I-3106171664_TS-SYSAUX_FNO-3_02kvjg03bak tag=TEST DUPLICATE DB recid=2 stamp=704233483
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile fno=00002 name=/orainstall/oradata/target/undotbs01.dbf
output filename=/orainstall/rmanbak/data_D-TARGET_I-3106171664_TS-UNDOTBS1_FNO-2_03kvjg0jbak tag=TEST DUPLICATE DB recid=3 stamp=704233492
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile fno=00004 name=/orainstall/oradata/target/users01.dbf
output filename=/orainstall/rmanbak/data_D-TARGET_I-3106171664_TS-USERS_FNO-4_04kvjg0nbak tag=TEST DUPLICATE DB recid=4 stamp=704233495
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
copying current control file
output filename=/orainstall/rmanbak/cf_D-TARGET_id-3106171664_05kvjg0obak tag=TEST DUPLICATE DB recid=5 stamp=704233497
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting incremental level 0 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 29-NOV-09
channel ORA_DISK_1: finished piece 1 at 29-NOV-09
piece handle=/orainstall/rmanbak/06kvjg0q_1_1bak tag=TEST DUPLICATE DB comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-NOV-09

RMAN> sql 'alter system archive log current';

6,根據target庫的密碼檔案相關資訊,在duplicate庫上面構建對應的密碼檔案
target

-bash-3.00$ cd $ORACLE_HOME/dbs
-bash-3.00$ ls
ab_+ASM1.dat      hc_target.dat     init.ora          lkTARGET          orapwtarget       spfiletarget.ora
hc_+ASM1.dat      init+ASM1.ora     initdw.ora        orapw+ASM1        snapcf_target.f

duplicate
-bash-3.00$ cd $ORACLE_HOME/dbs
-bash-3.00$ ls -l orapwtarget

-bash-3.00$ orapwd file=./orapwtarget password=system entries=10 force=y

7,透過rcp把target庫的pfile(透過target的spfile構建)傳到duplicate對應的目錄下

-bash-3.00$ rcp ./target.ora  oracle@capitek2:/orainstall

8,同上利用rcp把target作的rman全備及歸檔日誌傳到duplicate庫對應目錄下

target

-bash-3.00$ pwd
/orainstall/rmanbak
-bash-3.00$ rcp ./* oracle@capitek2:/orainstall/rmanbak
-bash-3.00$ tar cvf x.tar flash_recovery_area/
a flash_recovery_area// 0K
a flash_recovery_area//TARGET/ 0K
a flash_recovery_area//TARGET/onlinelog/ 0K
a flash_recovery_area//TARGET/archivelog/ 0K
a flash_recovery_area//TARGET/archivelog/2009_11_29/ 0K
a flash_recovery_area//TARGET/archivelog/2009_11_29/o1_mf_1_3_5k4z49ql_.arc 48K

-bash-3.00$ rcp x.tar  oracle@capitek2:/orainstall
-bash-3.00$


duplicate

tar xvf x.tar

9,在target和duplicate,利用netca構建監聽器及相關的net服務名(duplicate上net服務名為aux),target上net服務名為target
  (note:在每個節點構建兩個net服務名),並用tnsping測試互通性
10,在duplicate上以nomount狀態啟動auxiliary instance
-bash-3.00$ export ORACLE_SID=aux
-bash-3.00$ sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Nov 29 20:51:27 2009

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup nomount pfile=/orainstall/target.ora
ORACLE instance started.

Total System Global Area 5083496448 bytes
Fixed Size                  1985656 bytes
Variable Size             905974664 bytes
Database Buffers         4160749568 bytes
Redo Buffers               14786560 bytes
SQL>

(注:---最好對輔助例項構建spfile.因為duplicate動作時,要重啟庫,所以要是用pfile,會提示找不到相關的檔案,還是spfile省時,讓oracle自己找)
-bash-3.00$ sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Nov 29 22:10:50 2009

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup nomount pfile='/orainstall/oracle/product/10.2.0/db_1/dbs/initaux.ora';
ORACLE instance started.

Total System Global Area 5083496448 bytes
Fixed Size                  1985656 bytes
Variable Size             905974664 bytes
Database Buffers         4160749568 bytes
Redo Buffers               14786560 bytes
SQL> create spfile from pfile='/orainstall/oracle/product/10.2.0/db_1/dbs/initaux.ora';

File created.
)

11,在duplicate上利用rman遷移複製庫出錯
-bash-3.00$ hostname
capitek2
export ORACLE_SID=aux
-bash-3.00$ rman target sys/system@target auxiliary sys/system

Recovery Manager: Release 10.2.0.1.0 - Production on Sun Nov 29 21:32:52 2009

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: TARGET (DBID=3106171664)
connected to auxiliary database: DUP (not mounted)

RMAN> run {
2> allocate auxiliary channel ch1 device type disk;
3> duplicate target database to dup;
4> }

using target database control file instead of recovery catalog
allocated channel: ch1
channel ch1: sid=153 devtype=DISK

Starting Duplicate Db at 29-NOV-09
released channel: ch1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 11/29/2009 21:33:36
ORA-01405: fetched column value is NULL

RMAN>

處理:
在target庫上alter system switch logfile;

再次執行rman run塊

RMAN> run {
2> allocate auxiliary channel ch1 device type disk;
3> duplicate target database to dup;
4> }

allocated channel: ch1
channel ch1: sid=153 devtype=DISK

Starting Duplicate Db at 29-NOV-09

contents of Memory Script.:
{
   set until scn  544150;
   set newname for datafile  1 to
 "/orainstall/oradata/dup/system01.dbf";
   set newname for datafile  2 to
 "/orainstall/oradata/dup/undotbs01.dbf";
   set newname for datafile  3 to
 "/orainstall/oradata/dup/sysaux01.dbf";
   set newname for datafile  4 to
 "/orainstall/oradata/dup/users01.dbf";
   restore
   check readonly
   clone database
   ;
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 29-NOV-09

channel ch1: restoring datafile 00001
input datafile copy recid=1 stamp=704233466 filename=/orainstall/rmanbak/data_D-TARGET_I-3106171664_TS-SYSTEM_FNO-1_01kvjfvabak
destination for restore of datafile 00001: /orainstall/oradata/dup/system01.dbf
channel ch1: copied datafile copy of datafile 00001
output filename=/orainstall/oradata/dup/system01.dbf
channel ch1: restoring datafile 00002
input datafile copy recid=3 stamp=704233492 filename=/orainstall/rmanbak/data_D-TARGET_I-3106171664_TS-UNDOTBS1_FNO-2_03kvjg0jbak
destination for restore of datafile 00002: /orainstall/oradata/dup/undotbs01.dbf
channel ch1: copied datafile copy of datafile 00002
output filename=/orainstall/oradata/dup/undotbs01.dbf
channel ch1: restoring datafile 00003
input datafile copy recid=2 stamp=704233483 filename=/orainstall/rmanbak/data_D-TARGET_I-3106171664_TS-SYSAUX_FNO-3_02kvjg03bak
destination for restore of datafile 00003: /orainstall/oradata/dup/sysaux01.dbf
channel ch1: copied datafile copy of datafile 00003
output filename=/orainstall/oradata/dup/sysaux01.dbf
channel ch1: restoring datafile 00004
input datafile copy recid=4 stamp=704233495 filename=/orainstall/rmanbak/data_D-TARGET_I-3106171664_TS-USERS_FNO-4_04kvjg0nbak
destination for restore of datafile 00004: /orainstall/oradata/dup/users01.dbf
channel ch1: copied datafile copy of datafile 00004
output filename=/orainstall/oradata/dup/users01.dbf
Finished restore at 29-NOV-09
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DUP" RESETLOGS ARCHIVELOG
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP  1 ( '/orainstall/oradata/dup/redo01.log' ) SIZE 50 M  REUSE,
  GROUP  2 ( '/orainstall/oradata/dup/redo02.log' ) SIZE 50 M  REUSE,
  GROUP  3 ( '/orainstall/oradata/dup/redo03.log' ) SIZE 50 M  REUSE
 DATAFILE
  '/orainstall/oradata/dup/system01.dbf'
 CHARACTER SET ZHS16GBK


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

datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=704237834 filename=/orainstall/oradata/dup/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=704237834 filename=/orainstall/oradata/dup/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=704237834 filename=/orainstall/oradata/dup/users01.dbf

contents of Memory Script.:
{
   set until scn  544150;
   recover
   clone database
    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 29-NOV-09

starting media recovery

Oracle Error:
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01152: file 2 was not restored from a sufficiently old backup
ORA-01110: data file 2: '/orainstall/oradata/dup/undotbs01.dbf'

released channel: ch1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 11/29/2009 21:37:20
RMAN-03015: error occurred in stored script. Memory Script
RMAN-06053: unable to perform. media recovery because of missing log
RMAN-06025: no backup of log thread 1 seq 2 lowscn 530402 found to restore

RMAN>


還是出錯


再次修正後,還是出錯(重新備份全庫及歸檔,傳到duplicate)
-bash-3.00$ rman target sys/system@target auxiliary sys/system

Recovery Manager: Release 10.2.0.1.0 - Production on Sun Nov 29 21:59:31 2009

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: TARGET (DBID=3106171664)
connected to auxiliary database: DUP (not mounted)

RMAN> run {
2> allocate auxiliary channel ch1 device type disk;
3>  duplicate target database to dup;
4> }

using target database control file instead of recovery catalog
allocated channel: ch1
channel ch1: sid=153 devtype=DISK

Starting Duplicate Db at 29-NOV-09

contents of Memory Script.:
{
   set until scn  544558;
   set newname for datafile  1 to
 "/orainstall/oradata/dup/system01.dbf";
   set newname for datafile  2 to
 "/orainstall/oradata/dup/undotbs01.dbf";
   set newname for datafile  3 to
 "/orainstall/oradata/dup/sysaux01.dbf";
   set newname for datafile  4 to
 "/orainstall/oradata/dup/users01.dbf";
   restore
   check readonly
   clone database
   ;
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 29-NOV-09

channel ch1: restoring datafile 00001
input datafile copy recid=6 stamp=704238671 filename=/orainstall/rmanbak/data_D-TARGET_I-3106171664_TS-SYSTEM_FNO-1_07kvjl1vbak
destination for restore of datafile 00001: /orainstall/oradata/dup/system01.dbf
channel ch1: copied datafile copy of datafile 00001
output filename=/orainstall/oradata/dup/system01.dbf
channel ch1: restoring datafile 00002
input datafile copy recid=8 stamp=704238697 filename=/orainstall/rmanbak/data_D-TARGET_I-3106171664_TS-UNDOTBS1_FNO-2_09kvjl38bak
destination for restore of datafile 00002: /orainstall/oradata/dup/undotbs01.dbf
channel ch1: copied datafile copy of datafile 00002
output filename=/orainstall/oradata/dup/undotbs01.dbf
channel ch1: restoring datafile 00003
input datafile copy recid=7 stamp=704238688 filename=/orainstall/rmanbak/data_D-TARGET_I-3106171664_TS-SYSAUX_FNO-3_08kvjl2pbak
destination for restore of datafile 00003: /orainstall/oradata/dup/sysaux01.dbf
channel ch1: copied datafile copy of datafile 00003
output filename=/orainstall/oradata/dup/sysaux01.dbf
channel ch1: restoring datafile 00004
input datafile copy recid=9 stamp=704238700 filename=/orainstall/rmanbak/data_D-TARGET_I-3106171664_TS-USERS_FNO-4_0akvjl3cbak
destination for restore of datafile 00004: /orainstall/oradata/dup/users01.dbf
channel ch1: copied datafile copy of datafile 00004
output filename=/orainstall/oradata/dup/users01.dbf
Finished restore at 29-NOV-09
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DUP" RESETLOGS ARCHIVELOG
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP  1 ( '/orainstall/oradata/dup/redo01.log' ) SIZE 50 M  REUSE,
  GROUP  2 ( '/orainstall/oradata/dup/redo02.log' ) SIZE 50 M  REUSE,
  GROUP  3 ( '/orainstall/oradata/dup/redo03.log' ) SIZE 50 M  REUSE
 DATAFILE
  '/orainstall/oradata/dup/system01.dbf'
 CHARACTER SET ZHS16GBK


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

datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=704239294 filename=/orainstall/oradata/dup/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=704239294 filename=/orainstall/oradata/dup/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=704239294 filename=/orainstall/oradata/dup/users01.dbf

contents of Memory Script.:
{
   set until scn  544558;
   recover
   clone database
    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 29-NOV-09

starting media recovery

archive log thread 1 sequence 3 is already on disk as file /orainstall/flash_recovery_area/TARGET/archivelog/2009_11_29/o1_mf_1_3_5k4z49ql_.arc
archive log filename=/orainstall/flash_recovery_area/TARGET/archivelog/2009_11_29/o1_mf_1_3_5k4z49ql_.arc thread=1 sequence=3
media recovery complete, elapsed time: 00:00:03
Finished recover at 29-NOV-09

contents of Memory Script.:
{
   shutdown clone;
   startup clone nomount ;
}
executing Memory Script

database dismounted
Oracle instance shut down

connected to auxiliary database (not started)
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/orainstall/oracle/product/10.2.0/db_1/dbs/initaux.ora'

starting Oracle instance without parameter file for retrival of spfile
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 11/29/2009 22:03:13
RMAN-03015: error occurred in stored script. Memory Script
RMAN-04014: startup failed: ORA-04031: unable to allocate 4096 bytes of shared memory ("shared pool","unknown object","sga heap(1,0)","kglsim hash table bkts")

RMAN> exit





---再次經過修正後執行

RMAN> run {
2> allocate auxiliary channel ch1 device type disk;
3> duplicate target database to dup;
4> }

using target database control file instead of recovery catalog
allocated channel: ch1
channel ch1: sid=153 devtype=DISK

Starting Duplicate Db at 29-NOV-09

contents of Memory Script.:
{
   set until scn  544558;
   set newname for datafile  1 to
 "/orainstall/oradata/dup/system01.dbf";
   set newname for datafile  2 to
 "/orainstall/oradata/dup/undotbs01.dbf";
   set newname for datafile  3 to
 "/orainstall/oradata/dup/sysaux01.dbf";
   set newname for datafile  4 to
 "/orainstall/oradata/dup/users01.dbf";
   restore
   check readonly
   clone database
   ;
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 29-NOV-09

channel ch1: restoring datafile 00001
input datafile copy recid=6 stamp=704238671 filename=/orainstall/rmanbak/data_D-TARGET_I-3106171664_TS-SYSTEM_FNO-1_07kvjl1vbak
destination for restore of datafile 00001: /orainstall/oradata/dup/system01.dbf
channel ch1: copied datafile copy of datafile 00001
output filename=/orainstall/oradata/dup/system01.dbf
channel ch1: restoring datafile 00002
input datafile copy recid=8 stamp=704238697 filename=/orainstall/rmanbak/data_D-TARGET_I-3106171664_TS-UNDOTBS1_FNO-2_09kvjl38bak
destination for restore of datafile 00002: /orainstall/oradata/dup/undotbs01.dbf
channel ch1: copied datafile copy of datafile 00002
output filename=/orainstall/oradata/dup/undotbs01.dbf
channel ch1: restoring datafile 00003
input datafile copy recid=7 stamp=704238688 filename=/orainstall/rmanbak/data_D-TARGET_I-3106171664_TS-SYSAUX_FNO-3_08kvjl2pbak
destination for restore of datafile 00003: /orainstall/oradata/dup/sysaux01.dbf
channel ch1: copied datafile copy of datafile 00003
output filename=/orainstall/oradata/dup/sysaux01.dbf
channel ch1: restoring datafile 00004
input datafile copy recid=9 stamp=704238700 filename=/orainstall/rmanbak/data_D-TARGET_I-3106171664_TS-USERS_FNO-4_0akvjl3cbak
destination for restore of datafile 00004: /orainstall/oradata/dup/users01.dbf
channel ch1: copied datafile copy of datafile 00004
output filename=/orainstall/oradata/dup/users01.dbf
Finished restore at 29-NOV-09
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DUP" RESETLOGS ARCHIVELOG
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP  1 ( '/orainstall/oradata/dup/redo01.log' ) SIZE 50 M  REUSE,
  GROUP  2 ( '/orainstall/oradata/dup/redo02.log' ) SIZE 50 M  REUSE,
  GROUP  3 ( '/orainstall/oradata/dup/redo03.log' ) SIZE 50 M  REUSE
 DATAFILE
  '/orainstall/oradata/dup/system01.dbf'
 CHARACTER SET ZHS16GBK


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

datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=704240118 filename=/orainstall/oradata/dup/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=704240118 filename=/orainstall/oradata/dup/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=704240118 filename=/orainstall/oradata/dup/users01.dbf

contents of Memory Script.:
{
   set until scn  544558;
   recover
   clone database
    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 29-NOV-09

starting media recovery

archive log thread 1 sequence 3 is already on disk as file /orainstall/flash_recovery_area/TARGET/archivelog/2009_11_29/o1_mf_1_3_5k4z49ql_.arc
archive log filename=/orainstall/flash_recovery_area/TARGET/archivelog/2009_11_29/o1_mf_1_3_5k4z49ql_.arc thread=1 sequence=3
media recovery complete, elapsed time: 00:00:03
Finished recover at 29-NOV-09

contents of Memory Script.:
{
   shutdown clone;
   startup clone nomount ;
}
executing Memory Script

database dismounted
Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area    5083496448 bytes

Fixed Size                     1985656 bytes
Variable Size                905974664 bytes
Database Buffers            4160749568 bytes
Redo Buffers                  14786560 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DUP" RESETLOGS ARCHIVELOG
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP  1 ( '/orainstall/oradata/dup/redo01.log' ) SIZE 50 M  REUSE,
  GROUP  2 ( '/orainstall/oradata/dup/redo02.log' ) SIZE 50 M  REUSE,
  GROUP  3 ( '/orainstall/oradata/dup/redo03.log' ) SIZE 50 M  REUSE
 DATAFILE
  '/orainstall/oradata/dup/system01.dbf'
 CHARACTER SET ZHS16GBK


contents of Memory Script.:
{
   set newname for tempfile  1 to
 "/orainstall/oradata/dup/temp01.dbf";
   switch clone tempfile all;
   catalog clone datafilecopy  "/orainstall/oradata/dup/undotbs01.dbf";
   catalog clone datafilecopy  "/orainstall/oradata/dup/sysaux01.dbf";
   catalog clone datafilecopy  "/orainstall/oradata/dup/users01.dbf";
   switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

renamed temporary file 1 to /orainstall/oradata/dup/temp01.dbf in control file

cataloged datafile copy
datafile copy filename=/orainstall/oradata/dup/undotbs01.dbf recid=1 stamp=704240229

cataloged datafile copy
datafile copy filename=/orainstall/oradata/dup/sysaux01.dbf recid=2 stamp=704240230

cataloged datafile copy
datafile copy filename=/orainstall/oradata/dup/users01.dbf recid=3 stamp=704240230

datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=704240229 filename=/orainstall/oradata/dup/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=704240230 filename=/orainstall/oradata/dup/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=704240230 filename=/orainstall/oradata/dup/users01.dbf

contents of Memory Script.:
{
   Alter clone database open resetlogs;
}
executing Memory Script

database opened
Finished Duplicate Db at 29-NOV-09

RMAN>

--一切ok


總結:
1,看官方文件一定要仔細,細小的地方要多看,千萬別略過,可能就是哪兒導致 你實施不成功
2,target和duplicate的目錄結構要一致(此指儲存data file,tempfile,log file)
3,一定要對target庫進行全庫備份後來一個alter system switch logfile.這個東東在duplicate時會用到(也就是所謂的一致性恢復,說白了就是歸檔日誌)
4,根據target的spfile,建立用於auxiliary instance的spfile,然後mount,根據pfile構建spfile(至關重要,因為rman duplicate指令碼會有一個重啟庫的過程,你用pfile會提示找到這個pfile,導致duplicate過程執行memory script失敗)
5,硬體環境及軟體環境:
   sun t2000兩臺
   os:solaris 10
   oracle version:oracle1201

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-620956/,如需轉載,請註明出處,否則將追究法律責任。

相關文章