11g RMANでActive Database Duplication
1. 検証環境

VMWareサーバー db-node01 複製先:DUPOMR
VMWareサーバー db-node02 ソースDB:OMR

2. 複製DBの初期化パラメータファイルの作成(db-node01)
[dbs oracle()] cd $ORACLE_HOME/dbs
[dbs oracle()] cat initDUPOMR.ora 
db_name=DUPOMR
[dbs oracle()]
3. 複製先で必要なディレクトリ構造を作成(db-node01)
[dbs oracle()] mkdir -p /u01/app/oracle/oradata/DUPOMR
[dbs oracle()] mkdir -p /u01/app/oracle/admin/DUPOMR/adump
[dbs oracle()] mkdir -p /u01/app/oracle/bak/DUPOMR/arch
[dbs oracle()] mkdir -p /u01/app/oracle/bak/DUPOMR/rman
4. 複製先のリスナーにSIDを登録(db-node01)
[admin oracle()] cat listener.ora 
LISTENER=
  (DESCRIPTION=
    (ADDRESS_LIST=
      (ADDRESS=(PROTOCOL=tcp)(HOST=db-node01)(PORT=1521))))
SID_LIST_LISTENER=
  (SID_LIST=
    (SID_DESC=
      (SID_NAME=PROD)
      (ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1))
  (SID_LIST=
    (SID_DESC=
      (SID_NAME=DUPOMR)
      (ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1)))
[admin oracle()] lsnrctl reload

LSNRCTL for Linux: Version 11.1.0.7.0 - Production on 02-DEC-2009 00:08:53

Copyright (c) 1991, 2008, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db-node01)(PORT=1521)))
The command completed successfully
[admin oracle()]
5. 複製先DBのパスワードファイル作成(db-node01)
[dbs oracle()] scp db-node02:/u01/app/oracle/product/11.1.0/db_1/dbs/orapwOMR ./orapwDUPOMR
orapwOMR                                                                     100% 1536     1.5KB/s   00:00    
[dbs oracle()]
6. ソースDBのtnsnames.oraに複製先DB情報を追加(db-node02)
[admin oracle()] cat tnsnames.ora 
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.1.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

DUPOMR =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = db-node01)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = DUPOMR)
    )
  )
[admin oracle()]
7. 複製先DBをNOMOUNTに起動(db-node02)
[work oracle()] sqlplus sys/oracle@DUPOMR as sysdba

SQL*Plus: Release 11.1.0.7.0 - Production on Wed Dec 2 00:23:42 2009

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

Connected to an idle instance.

DUPOMR(SYS)> startup nomount
ORACLE instance started.

Total System Global Area  150667264 bytes
Fixed Size                  1311940 bytes
Variable Size              92277564 bytes
Database Buffers           50331648 bytes
Redo Buffers                6746112 bytes
DUPOMR(SYS)>
8. ソースDBでRMANを起動(db-node02)
[work oracle(OMR)] rman target / auxiliary=sys/oracle@dupomr

Recovery Manager: Release 11.1.0.7.0 - Production on Wed Dec 2 00:29:17 2009

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

connected to target database: OMR (DBID=1350152268)
connected to auxiliary database: DUPOMR (not mounted)

RMAN>
9. Active Database Duplication実行(db-node02)
RMAN> DUPLICATE TARGET DATABASE TO DUPOMR
  FROM ACTIVE DATABASE
  SPFILE 
    PARAMETER_VALUE_CONVERT 'OMR', 'DUPOMR'
    SET DB_FILE_NAME_CONVERT 'OMR','DUPOMR'
    SET LOG_FILE_NAME_CONVERT 'OMR','DUPOMR';

Starting Duplicate Db at 02-DEC-09
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=98 device type=DISK

contents of Memory Script:
{
   backup as copy reuse
   file  '/u01/app/oracle/product/11.1.0/db_1/dbs/spfileOMR.ora' auxiliary format 
 '/u01/app/oracle/product/11.1.0/db_1/dbs/spfileDUPOMR.ora'   ;
   sql clone "alter system set spfile= ''/u01/app/oracle/product/11.1.0/db_1/dbs/spfileDUPOMR.ora''";
}
executing Memory Script

Starting backup at 02-DEC-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=131 device type=DISK
Finished backup at 02-DEC-09

sql statement: alter system set spfile= ''/u01/app/oracle/product/11.1.0/db_1/dbs/spfileDUPOMR.ora''

contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ''DUPOMR'' comment=
 ''duplicate'' scope=spfile";
   sql clone "alter system set  audit_file_dest = 
 ''/u01/app/oracle/admin/DUPOMR/adump'' comment=
 '''' scope=spfile";
   sql clone "alter system set  control_files = 

... ... 略

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=704508245 file name=/u01/app/oracle/oradata/DUPOMR/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=704508245 file name=/u01/app/oracle/oradata/DUPOMR/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=704508245 file name=/u01/app/oracle/oradata/DUPOMR/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=704508246 file name=/u01/app/oracle/oradata/DUPOMR/mgmt.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=704508246 file name=/u01/app/oracle/oradata/DUPOMR/mgmt_ecm_depot1.dbf

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

database opened
Finished Duplicate Db at 02-DEC-09

RMAN>
10. 複製先DUPOMRインスタンスの確認(db-node01)
[work oracle()] export ORACLE_SID=DUPOMR
[work oracle(DUPOMR)] sqlplus / as sysdba

SQL*Plus: Release 11.1.0.7.0 - Production on Wed Dec 2 00:45:41 2009

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

DUPOMR(SYS)> select  dbid,name,open_mode from v$database;

      DBID NAME      OPEN_MODE
---------- --------- ----------
 684395602 DUPOMR    READ WRITE

DUPOMR(SYS)> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/bak/DUPOMR/arch
Oldest online log sequence     1
Next log sequence to archive   1
Current log sequence           1
DUPOMR(SYS)>
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License