RMAN 'Duplicate From Active Database' Feature in Oracle11g (Doc ID 452868.1)

RMAN 'Duplicate From Active Database' Feature in Oracle11g (Doc ID 452868.1)

APPLIES TO:

Oracle Database - Enterprise Edition - Version 11.1.0.6 and later
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Express Cloud Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Information in this document applies to any platform.
Checked for relevance on 21-AUG-2015

PURPOSE

The scope of this bulletin is to discuss the different type of RMAN 'duplicate database' feature in Oracle 11G.

Scope of this bulletin is to discuss the different types of Oracle 11G RMAN 'duplicate database' function

This note is only applicable for oracle 11g    only. This applies only to oracle 11g

In case you may want or need more about your current topic - please also access the Backup & Recover Community of Customers and Oracle Specialists directly via:
https://community.oracle.com/community/support/oracle_database/database_backup_and_recovery


If you want to DUPLICATE FOR STANDBY, than check Note 1075908.1 Step by Step Guide on Creating Physical Standby Using RMAN DUPLICATE...FROM ACTIVE DATABASE

如果要 DUPLICATE FOR STANDBY,请Note 1075908.1 Step by Step Guide on Creating Physical Standby Using RMAN DUPLICATE...FROM ACTIVE DATABASE

SCOPE

This note is intended for DBAs and Support Personnel.

DETAILS

You can create a duplicate database using the RMAN duplicate command. The duplicate database has a different DBID from the source database and functions entirely independently.Starting from 11g you can do duplicate database in 2 ways.

You can create a duplicate database using RMAN duplicate command. Different copy of the database DBID DBID of the source database, and is completely independent operation. 11g from the start, you can create a replicated database in two ways

1. Active database duplication 
2. Backup-based duplication

Active database duplication copies the live target database over the network to the auxiliary destination and then creates the duplicate database.Only difference is that you don't need to have the pre-existing RMAN backups and copies.The duplication work is performed by an auxiliary channel.This channel corresponds to a server session on the auxiliary instance on the auxiliary host.

Active database duplication to copy the target database through the network activity to assist the target location, and then create a replicate database. The only difference is that you do not need to have RMAN backups and copies pre-existing. Corresponding to the channel on the auxiliary instance on the secondary host server session copying operation performed by the auxiliary database

As part of the duplicating operation, RMAN  automates the following steps: As part of the copy operation, RMAN automatically performs the following steps

1. Creates a control file for the duplicate   database create a control file for the replicate database
2. Restarts the auxiliary instance and mounts the duplicate control file   restart and install auxiliary instance control file is copied
3. Creates the duplicate datafiles and recovers them   with incremental backups and archived redo logs. Creating copy the data files and use incremental backups and archived redo logs to restore them
4. Opens the duplicate database with the RESETLOGS option   with the RESETLOGS option to open duplicate database

For the active database duplication, RMAN does one extra step .ie copy the target database datafiles over the network to the auxiliary instance

For the active database duplication, RMAN will perform an extra step. I.e., copied to the secondary target database instance data files through a network.

A RAC TARGET database can be duplicated as well. The procedure is the same as below. If the auxiliary instance needs to be a RAC-database as well, than start the duplicate procedure for to a single instance and convert the auxiliary to RAC after the duplicate has succeeded.
RAC TARGET database can be copied. The following steps are the same. If you also need to be assisted instance RAC database, it will start to replicate the success of its single instance of the replication process, and then convert the secondary instance to RAC.

Scope of this note is restricted to Active database duplication . For the Backup-base duplication refer Note 259694.1 Oracle10G RMAN Database Duplication.

The scope of the description is limited to the Active database duplication. About the Backup-base duplication, see  Note 259,694.1  Oracle10G RMAN Database Duplication.

Basic Steps to ACTIVE database duplication:   Basic Steps

1. Preparing the auxiliary instance:   preparing auxiliary instance

1.1 Creating initialization Parameter file for the Auxiliary   instance create an initialization parameter file for the auxiliary instance

If you are using SPFILE then only parameter required for the duplicate database is DB_NAME . Rest other parameters can be set in the DUPLICATE command itself.If you are not using the SPFILE technique, then you need to set initialization parameters to set in the initialization parameter file. Required parameters are :

If you are using SPFILE, the only parameter needed to repeat the database is DB_NAME. The rest of the other parameters can be set at DUPLICATE command itself. If you do not use SPFILE, you need to set initialization parameters to be set in the initialization parameter file. Required parameter is

DB_NAME
CONTROL_FILES
DB_BLOCK_SIZE
DB_FILE_NAME_CONVERT
LOG_FILE_NAME_CONVERT
DB_RECOVERY_FILE_DEST

In this bulletin for simplicity we are specifying all the required parameters in the pfile.  For example:

For simplicity, in this announcement, we specify all the necessary parameters in the pfile. E.g

init<DB_NAME>.ora
------------
DB_NAME=<DB_NAME>
diagnostic_dest='E:\oracle' 
DB_FILE_name_CONVERT=('I:\<old_path>\','E:\<new_path>\') 
LOG_FILE_NAME_CONVERT=('I:\<old_path>\','E:\<new_path>\')
SGA_TARGET=262144000 
CONTROL_FILES='E:\<PATH>\control01.dbf' 
COMPATIBLE= 11.1.0.0.0

1.2 Create an Oracle Password File for the   Auxiliary Instance Create an Oracle password file for the auxiliary instance

Password file is must for the Active database duplication.A password file is not required for backup-based duplication. For Active database duplication it connects directly to the auxiliary instance using the password file with the same SYSDBA password as target database. In case you are using password file make sure to have same SYSDBA password as the target database.Also you can specify the PASSWORD FILE option on the DUPLICATE command.In this case, RMAN copies the source database password file to the destination host and overwrites any existing password file for the auxiliary instance.

Active database duplication must enter the password file. Based on the duplication backup file without a password. For Active database duplication, it uses the same target database SYSDBA password password file is directly connected to the auxiliary instance. If you want to use a password file, make sure the target database has the same SYSDBA password. In addition, you can also specify the PASSWORD FILE option on the DUPLICATE command. In this case, RMAN copy the source database to the target host password file and overwrite the existing password file any auxiliary instance.

In this bulletin we are using password file  option in the duplicate command. In this bulletin, we use password file option in duplicate command

Create the database service (only for windows) and password file.  For example :

Create a database service (only for Windows) and password file. E.g:

 

% set ORACLE_SID=<oracle_sid>
% set ORACLE_HOME=E:\<oracle_home>
% oradim -NEW -SID <oracle_sid>
% orapwd FILE=E:\<oracle_home\database\PWDTEST.ora PASSWORD=<password>

 

 

For Unix / Linux the service is not  needed, only the password file.  For Unix / Linux, does not require service, you need only the password file

. 1.3 Start the Auxiliary instance in NOMOUNT   For example: start the auxiliary instance in NOMOUNT in. E.g

 

% sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Wed Aug 1 20:33:30 2007

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

Connected to an idle instance.

SQL> startup NOMOUNT pfile=E:\<oracle_home>\database\init<oracle_sid>.ora
ORACLE instance started.

Total System Global Area  150667264 bytes
Fixed Size                  1331732 bytes
Variable Size              92278252 bytes
Database Buffers           50331648 bytes
Redo Buffers                6725632 bytes
SQL> exit 

2. Create the necessary oracle NET connectivity.     Creating the necessary oracle NET connection

2.1 Insert a static entry for the auxiliary in the listener.ora file on the auxiliary server.  In addition, tnsnames.ora entry is needed in both target and auxiliary.  For example :

Insert a static entry for the secondary server in the listener.ora file on the secondary server. In addition, goals and assisted directory requires tnsnames.ora entry. E.g 

Listener.ora (on the AUXILIARY host)
------------
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME =<DB_NAME>)
      (ORACLE_HOME = E:\<oracle_home>)
      (SID_NAME = <oracle_sid>)
    )
  )


LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = <host name>)(PORT = 1521))
  )
tnsname.ora (In the TARGET and AUXILIARY host)
-----------
## For the Auxiliary database <auxiliary db> ##
<auxiliary db>= 
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = <host name>)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = <auxiliary oracle sid>)
    )
  )

## For the target database <target db> ##
<target db>=
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = <host name>)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = <target oracle sid>)
    )
  )## Similarly add entry for the catalog database ( Optional) 

 

2.1 Check connectivity between target and auxiliary instances   : the connectivity between the inspection target instance and auxiliary instance

Execute on the TARGET and AUXILIARY host
% tnsping <target database>
% tnsping <auxiliary database>

3. Start RMAN and Connect to the Database   Instances start RMAN and connect to a database instance

Start RMAN and connect to the source database as TARGET, the duplicate database instance as AUXILIARY, and, if applicable, the recovery catalog database.You can start the RMAN client on any host so long as it can connect to all of the database instances. 
the Auxiliary instance a the requires IF text-based Initialization Parameter File, the then the this MUST exist ON File the Same Host the RMAN Client file application that the runs. - examples start RMAN and connect to TARGET identity to the source database, the database is replicated to the AUXILIARY form connected to the recovery catalog database (if applicable), and the connection is restored directory database. You can start the RMAN client on any host, as long as it can connect to all database instances can be. If the auxiliary instance requires initialization parameter file based on the text, the file must exist on the same host running the RMAN client application. AGRICULTURAL SCIENCE. WE are doing the this an In Duplicate Database from Server Look at The Auxiliary at The AT Example:. - In this announcement, we are copying from the secondary database server. See examples % rman
Recovery Manager: Release 11.1.0.6.0 - Production on Wed Aug 1 21:06:49 2007 Copyright (c) 1982, 2007, Oracle. All rights reserved. RMAN> connect TARGET sys/<password>@<target_service>; ## Target database ## connected to target database: <target DB_NAME> (DBID=<value>) RMAN> connect AUXILIARY sys/<password>@<auxiliary_service>; ## Auxiliary database ## connected to auxiliary database: <auxiliary DB_NAME>(not mounted) RMAN> connect CATALOG <catalog_schema>/<password>@<catalog database service>; ## Catalog database .Optional ## connected to recovery catalog database

4. Run the DUPLICATE database command:   Run Database DUPLICATE command

The simplest case is to use active database duplication to duplicate the database to a different host and use the different directory structure.Look at the example :

The simplest case is to use active database duplication to copy the database to other hosts and use a different directory structure. Consider the following example:

This example assumes

This example assumes the following:  This example assumes the following

* Using a recovery catalog.   Recovery catalog
* The target database is on host1 and   contains 4 datafiles. Target database is on host1, and contains four data files
* Duplicate the target to a database on the different host having different file   structure. copy the target to the database on different hosts have different file structure
* tablespace USERS in target is read-   only tablespace. target table space is read-only table space USERS
* Running duplicate database site at the auxiliary from.   Duplicate Database run from the secondary site

RMAN> DUPLICATE TARGET DATABASE 
      TO '<DB_NAME>'
      FROM ACTIVE DATABASE
      DB_FILE_NAME_CONVERT 'I:\<old_PATH>','E:\<new_PATH>';

 And this is what is going on:  how is this going

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

contents of Memory Script:
{
   set newname for datafile  1 to "E:\<PATH>\SYSTEM01.DBF";
   set newname for datafile  2 to "E:\<PATH>\SYSAUX01.DBF";
   set newname for datafile  3 to "E:\<PATH>\UNDOTBS01.DBF";
   set newname for datafile  4 to "E:\<PATH>\USERS01.DBF";
   backup as copy reuse
   datafile  1 auxiliary format  "E:\<PATH>\SYSTEM01.DBF"  
   datafile  2 auxiliary format  "E:\<PATH>\SYSAUX01.DBF"  
   datafile  3 auxiliary format  "E:\<PATH>\UNDOTBS01.DBF"  
   datafile  4 auxiliary format  "E:\<PATH>\USERS01.DBF"   ;
   sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME

Starting backup at 02-AUG-07
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=123 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=I:\<target PATH>\SYSTEM01.DBF
output file name=E:\<auxiliary PATH>\SYSTEM01.DBF tag=TAG20070802T114254 RECID=0 STAMP=0
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:08:22
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=I:\<target_PATH>\SYSAUX01.DBF
output file name=E:\<auxiliary PATH>\SYSAUX01.DBF tag=TAG20070802T114254 RECID=0 STAMP=0
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:05:59
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=I:\<target_PATH>\UNDOTBS01.DBF
output file name=E:\<auxiliary PATH>\UNDOTBS01.DBF tag=TAG20070802T114254 RECID=0 STAMP=0
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:02:57
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=I:\<target_PATH>\USERS01.DBF
output file name=E:\<auxiliary PATH>\USERS01.DBF tag=TAG20070802T114254 RECID=0 STAMP=0
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
Finished backup at 02-AUG-07

sql statement: alter system archive log current
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "<DB_NAME>" RESETLOGS ARCHIVELOG 
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP  1 ( 'E:\<auxiliary PATH>\REDO01.LOG' ) SIZE 50 M  REUSE,
  GROUP  2 ( 'E:\<auxiliary PATH>\REDO02.LOG' ) SIZE 50 M  REUSE,
  GROUP  3 ( 'E:\<auxiliary PATH>\REDO03.LOG' ) SIZE 50 M  REUSE
 DATAFILE
  'E:\<auxiliary PATH>\SYSTEM01.DBF'
 CHARACTER SET AL32UTF8

contents of Memory Script:
{
   backup as copy reuse
   archivelog like  "I:\<PATH>\ARC00042_0629061547.001" auxiliary format 
 "E:\<PATH>\ARC00042_0629061547.001"   archivelog like 
 "I:\<PATH>\O1_MF_1_42_3C2YJNP7_.ARC" auxiliary format 
 "E:\<PATH>\ARC00042_0629061547.001"   ;
   catalog clone archivelog  "E:\<PATH>\ARC00042_0629061547.001";
   catalog clone archivelog  "E:\<PATH>\ARC00042_0629061547.001";
   switch clone datafile all;
}
executing Memory Script

Starting backup at 02-AUG-07
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=42 RECID=35 STAMP=629553646
output file name=E:\<PATH>\ARC00042_0629061547.001 RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=42 RECID=36 STAMP=629553646
output file name=E:\<PATH>\ARC00042_0629061547.001 RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
Finished backup at 02-AUG-07

cataloged archived log
archived log file name=E:\<PATH>\ARC00042_0629061547.001 RECID=1 STAMP=629553800

cataloged archived log
archived log file name=E:\<PATH>\ARC00042_0629061547.001 RECID=2 STAMP=629553800

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=629553800 file name=E:\<auxiliary PATH>\SYSAUX01.DBF
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=629553801 file name=E:\<auxiliary PATH>\UNDOTBS01.DBF

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

executing command: SET until clause

Starting recover at 02-AUG-07
using channel ORA_AUX_DISK_1
datafile 4 not processed because file is read-only

starting media recovery

archived log for thread 1 with sequence 42 is already on disk as file E:\<PATH>\ARC00042_0629061547.001
archived log file name=E:\<PATH>\ARC00042_0629061547.001 thread=1 sequence=42
media recovery complete, elapsed time: 00:00:01
Finished recover at 02-AUG-07

contents of Memory Script:
{
   shutdown clone immediate;
   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     263639040 bytes

Fixed Size                     1332544 bytes
Variable Size                 83888832 bytes
Database Buffers             171966464 bytes
Redo Buffers                   6451200 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "<DB_NAME>" RESETLOGS ARCHIVELOG 
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP  1 ( 'E:\<auxiliary PATH>\REDO01.LOG' ) SIZE 50 M  REUSE,
  GROUP  2 ( 'E:\<auxiliary PATH>\REDO02.LOG' ) SIZE 50 M  REUSE,
  GROUP  3 ( 'E:\<auxiliary PATH>\REDO03.LOG' ) SIZE 50 M  REUSE
 DATAFILE
  'E:\<auxiliary_PATH>\SYSTEM01.DBF'
 CHARACTER SET AL32UTF8


contents of Memory Script:
{
   set newname for tempfile  1 to 
 "E:\<auxiliary PATH>\TEMP01.DBF";
   switch clone tempfile all;
   catalog clone datafilecopy  "E:\<auxiliary PATH>\SYSAUX01.DBF";
   catalog clone datafilecopy  "E:\<auxiliary PATH>\UNDOTBS01.DBF";
   switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to E:\<auxiliary PATH>\TEMP01.DBF in control file

cataloged datafile copy
datafile copy file name=E:\<auxiliary PATH>\SYSAUX01.DBF RECID=1 STAMP=629553825

cataloged datafile copy
datafile copy file name=E:\<auxiliary PATH>\UNDOTBS01.DBF RECID=2 STAMP=629553826

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=629553825 file name=E:\<auxiliary PATH>\SYSAUX01.DBF
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=629553826 file name=E:\<auxiliary PATH>\UNDOTBS01.DBF

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

database opened

contents of Memory Script:
{
   catalog clone datafilecopy  "E:\<auxiliary PATH>\USERS01.DBF";
   switch clone datafile  4 to datafilecopy  "E:\<auxiliary PATH>\USERS01.DBF";
#online the readonly tablespace
sql clone "alter tablespace  USERS online";
}
executing Memory Script

cataloged datafile copy
datafile copy file name=E:\<auxiliary PATH>\USERS01.DBF RECID=3 STAMP=629553870

datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=629553870 file name=E:\<auxiliary PATH>\USERS01.DBF

sql statement: alter tablespace  USERS online
Finished Duplicate Db at 02-AUG-07

  

Guess you like

Origin www.cnblogs.com/zylong-sys/p/12001696.html