續上_在同一節點上利用rman duplicate複製資料庫

wisdomone1發表於2009-11-30
1,根據target庫的spfile建立用於auxiliary instance的pfile
 注意相關的dump目錄要預先構建好,control_files要和duplicate庫配置成一致,其他和上節所述(兩機duplicate db)一樣
-bash-3.00$ more same.ora
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'
-bash-3.00$ env|grep SID
ORACLE_SID=ora10g1
-bash-3.00$ export ORACLE_SID=target

2,構建上述用於auxiliary instance所用到的相關目錄
-bash-3.00$ mkdir -p /orainstall/admin/dup
-bash-3.00$ mkdir -p /orainstall/admin/dup/cdump
-bash-3.00$ mkdir -p /orainstall/admin/dup/udump
-bash-3.00$ mkdir -p /orainstall/admin/dup/bdump
-bash-3.00$ mkdir -p /orainstall/admin/dup/adump
-bash-3.00$ mkdir -p /orainstall/oradata/dup

3,利用rman進行target庫的全備及歸檔操作
-bash-3.00$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Mon Nov 30 13:51:33 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 30-NOV-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=115 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_0rkvldl6bak tag=TEST DUPLICATE DB recid=23 stamp=704296630
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_0skvldlvbak tag=TEST DUPLICATE DB recid=24 stamp=704296647
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_0tkvldmfbak tag=TEST DUPLICATE DB recid=25 stamp=704296656
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005 name=/orainstall/oradata/target/test01.dbf
output filename=/orainstall/rmanbak/data_D-TARGET_I-3106171664_TS-NEWLY_FNO-5_0ukvldmibak tag=TEST DUPLICATE DB recid=26 stamp=704296659
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
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_0vkvldmkbak tag=TEST DUPLICATE DB recid=27 stamp=704296660
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_10kvldmlbak tag=TEST DUPLICATE DB recid=28 stamp=704296662
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 30-NOV-09
channel ORA_DISK_1: finished piece 1 at 30-NOV-09
piece handle=/orainstall/rmanbak/11kvldmn_1_1bak tag=TEST DUPLICATE DB comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 30-NOV-09

RMAN> sql 'alter system archive log current';

sql statement: alter system archive log current

RMAN> exit


Recovery Manager complete.

4,構建密碼檔案為auxiliary instance
-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
-bash-3.00$ orapwd
Usage: orapwd file= password= entries= force=

  where
    file - name of password file (mand),
    password - password for SYS (mand),
    entries - maximum number of distinct DBA and     force - whether to overwrite existing file (opt),
OPERs (opt),
  There are no spaces around the equal-to (=) character.
-bash-3.00$ orapwd file=./orapwaux password=system entries=10 force=y
-bash-3.00$ export ORACLE_SID=aux


5,根據上述的pfile檔案nomount auxiliary instance
-bash-3.00$ sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Nov 30 14:02:00 2009

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

Connected to an idle instance.

SQL> startup nomount pfile='/orainstall/same.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> exit   
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
-
6,利用netca在target節點上配置aux的net 服務名,完後用tnsping測試

bash-3.00$ tnsping aux

TNS Ping Utility for Solaris: Version 10.2.0.1.0 - Production on 30-NOV-2009 14:03:09

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

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.31.73)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = aux)))
OK (10 msec)
-bash-3.00$ tnsping aux

TNS Ping Utility for Solaris: Version 10.2.0.1.0 - Production on 30-NOV-2009 14:04:14

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

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.31.72)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = aux)))
OK (10 msec)
-bash-3.00$ tnsping target

TNS Ping Utility for Solaris: Version 10.2.0.1.0 - Production on 30-NOV-2009 14:04:19

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

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.31.72)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = target)))
OK (10 msec)



7,開啟rman,進行duplicate操作
export ORACLE_SID=aux

rman target sys/system@target auxiliary sys/system

Recovery Manager: Release 10.2.0.1.0 - Production on Mon Nov 30 15:47:44 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> pfile= /orainstall/same.ora   --注:我採用duplicate中和pfile選項
5> db_file_name_convert=('/orainstall/oradata/target/','/orainstall/oradata/dup/') --注:db_file_name_convert可寫在duplicate或pfile中
6> logfile  --採用duplicate的logfile選項(理解類似於log_file_name_convert功能,只不過log_file_name_convert只僅於pfile中
7> group 1 ('/orainstall/oradata/dup/redo01.log') size 50m,
8> group 2 ('/orainstall/oradata/dup/redo02.log') size 50m,
9> group 3 ('/orainstall/oradata/dup/redo03.log') size 50m reuse;---resuse就是若對應的日誌檔案存在,就會重寫它
10> }

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

Starting Duplicate Db at 30-NOV-09

contents of Memory Script.:
{
   set until scn  568184;
   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";
   set newname for datafile  5 to
 "/orainstall/oradata/dup/test01.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

executing command: SET NEWNAME

Starting restore at 30-NOV-09

channel ch1: restoring datafile 00001
input datafile copy recid=23 stamp=704296630 filename=/orainstall/rmanbak/data_D-TARGET_I-3106171664_TS-SYSTEM_FNO-1_0rkvldl6bak
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=25 stamp=704296656 filename=/orainstall/rmanbak/data_D-TARGET_I-3106171664_TS-UNDOTBS1_FNO-2_0tkvldmfbak
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=24 stamp=704296647 filename=/orainstall/rmanbak/data_D-TARGET_I-3106171664_TS-SYSAUX_FNO-3_0skvldlvbak
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=27 stamp=704296660 filename=/orainstall/rmanbak/data_D-TARGET_I-3106171664_TS-USERS_FNO-4_0vkvldmkbak
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
channel ch1: restoring datafile 00005
input datafile copy recid=26 stamp=704296659 filename=/orainstall/rmanbak/data_D-TARGET_I-3106171664_TS-NEWLY_FNO-5_0ukvldmibak
destination for restore of datafile 00005: /orainstall/oradata/dup/test01.dbf
channel ch1: copied datafile copy of datafile 00005
output filename=/orainstall/oradata/dup/test01.dbf
Finished restore at 30-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 ,
  GROUP  2 ( '/orainstall/oradata/dup/redo02.log' ) SIZE 50 M ,
  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=704303320 filename=/orainstall/oradata/dup/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=704303320 filename=/orainstall/oradata/dup/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=704303320 filename=/orainstall/oradata/dup/users01.dbf

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

executing command: SET until clause

Starting recover at 30-NOV-09
datafile 5 not processed because file is read-only

starting media recovery

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

contents of Memory Script.:
{
   shutdown clone;
   startup clone nomount pfile= '/orainstall/same.ora';
}
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 ,
  GROUP  2 ( '/orainstall/oradata/dup/redo02.log' ) SIZE 50 M ,
  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=704303433

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

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

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

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

database opened

contents of Memory Script.:
{
   catalog clone datafilecopy  "/orainstall/oradata/dup/test01.dbf";
   switch clone datafile  5 to datafilecopy
 "/orainstall/oradata/dup/test01.dbf";
#online the readonly tablespace
sql clone "alter tablespace  NEWLY online";
}
executing Memory Script

cataloged datafile copy
datafile copy filename=/orainstall/oradata/dup/test01.dbf recid=4 stamp=704303458

datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=704303458 filename=/orainstall/oradata/dup/test01.dbf

sql statement: alter tablespace  NEWLY online
Finished Duplicate Db at 30-NOV-09

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

相關文章