网站建设资讯

NEWS

网站建设资讯

DuplicateFromActiveDatabase

Duplicate From Active DatabaseRMAN 'Duplicate From Active Database' Feature in 11G (文档 ID 452868.1)Duplicate From Active Database转到底部Duplicate From Active Database

Duplicate From Active Database

网站建设哪家好,找创新互联建站!专注于网页设计、网站建设、微信开发、小程序制作、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了陵川免费建站欢迎大家使用!



APPLIES TO:

Oracle Database - Enterprise Edition - Version 11.1.0.6 and later
Information in this document applies to any platform.

PURPOSE

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

This note is only applicable for oracle 11g only. 

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

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.

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.

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

1. Creates a control file for the duplicate database 
2. Restarts the auxiliary instance and mounts the duplicate control file 
3. Creates the duplicate datafiles and recovers them with incremental backups and archived redo logs. 
4. Opens the duplicate database with the RESETLOGS option 

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

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.

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

Basic Steps to  ACTIVE database duplication :

1. Prepairing the auxiliary instance :

1.1 Creating 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 :

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

1.2 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.

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

1.3 Establish Oracle Net Connectivity to the Auxiliary Instance

Auxiliary instance must be available through Oracle Net if you are duplicating  from an ACTIVE database.

 1.4 Start the Auxiliary instance from Sqlplus

Use SQL*Plus to connect to the auxiliary instance and start it in NOMOUNT mode.

STEP S

In Auxiliary server :

1. Create the parameter file . Look at the example :

initTEST.ora
------------
DB_NAME=TEST 
diagnostic_dest='E:\oracle' 
DB_FILE_name_CONVERT=('I:\app\apadhi\oradata\amar','E:\oracle\oradata\test') 
LOG_FILE_NAME_CONVERT=( 'I:\app\apadhi\oradata\amar','E:\oracle\oradata\test')
SGA_TARGET=262144000 
CONTROL_FILES='E:\oracle\oradata\TEST\control01.dbf' 
COMPATIBLE= 11.1.0.0.0

 

2. Create the database service ( only for windows ) and password file . Look at the example :

% set ORACLE_SID=TEST
% set ORACLE_HOME=E:\oracle\product\11.1.0\db_1
% oradim -NEW -SID TEST
% orapwd FILE=E:\oracle\product\11.1.0\db_1\database\PWDTEST.ora PASSWORD=sys

For unix/Linux no need to create the service. Rest other steps are same.

 

3. Start the Auxiliary instance . Look at the example :

% 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\product\11.1.0\db_1\database\initTEST.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

 

4. Create the necessary oracle NET connectivity in the listener.ora and the tnsnames.ora file. Look at the example :

Listener.ora (on the AUXILIARY host)
------------
SID_LIST_LISTENER = 
  (SID_LIST = 
    (SID_DESC = 
      (GLOBAL_DBNAME = TEST) 
      (ORACLE_HOME = E:\oracle\product\11.1.0\db_1) 
      (SID_NAME = TEST) 
    ) 
  )


LISTENER = 
  (DESCRIPTION = 
    (ADDRESS = (PROTOCOL = TCP)(HOST = apadhi-idc)(PORT = 1521)) 
  )

tnsname.ora (In the TARGET and AUXILIARY host)
-----------
## For the Auxiliary database TEST ##TEST = 
  (DESCRIPTION = 
    (ADDRESS = (PROTOCOL = TCP)(HOST = apadhi-idc)(PORT = 1521)) 
    (CONNECT_DATA = 
      (SERVER = DEDICATED) 
      (SERVICE_NAME = TEST) 
    ) 
  ) 

## For the target database AMAR ##
AMAR = 
  (DESCRIPTION = 
    (ADDRESS = (PROTOCOL = TCP)(HOST = 152.69.210.76)(PORT = 1521)) 
    (CONNECT_DATA = 
      (SERVER = DEDICATED) 
      (SERVICE_NAME = AMAR) 
    ) 
  )## Similary add entry for the catalog database ( Optional)

Confirm the connection to both the target and the auxiliary instance using  sqlplus. In this example we are creating the duplicate database from the Auxiliary server.

Execute on the TARGET and AUXILIARY host
% tnsping AMAR
% tnsping TEST

 

 

2. Start RMAN and Connect to the Database Instances

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. If the auxiliary instance requires a text-based initialization parameter file, then this file must exist on the same host that runs the RMAN client application.

In this bulletin we are doing duplicate database from the auxiliary server. Look at the example :

% 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 / sys @ AMAR;   ## Target database ##
connected to target database: AMAR (DBID=1450838187) 

RMAN> connect AUXILIARY sys / sys @ TEST ;  ## Auxiliary database ##
connected to auxiliary database: TEST (not mounted) 

RMAN> connect CATALOG rman / rman @ CAT ; ## Catalog database .Optional ## 
connected to recovery catalog database

 

3. Run the DUPLICATE database 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 :

This example assumes

This example assumes the following: 

* Using a recovery catalog. 
* The target database is on host1 and contains 4 datafiles. 
* Duplicate the target to database TEST on the different  host having different file structure. 
* Tablespace USERS in target is read-only tablespace. 
* Running duplicate database from the Auxiliary site.

RMAN> DUPLICATE TARGET DATABASE  
      TO 'TEST' 
      FROM ACTIVE DATABASE 
      DB_FILE_NAME_CONVERT 'I:\app\apadhi\oradata\amar','E:\oracle\oradata\test';

 And this is what is going on:

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:\ORACLE\ORADATA\TEST\SYSTEM01.DBF"; 
   set newname for datafile  2 to "E:\ORACLE\ORADATA\TEST\SYSAUX01.DBF"; 
   set newname for datafile  3 to "E:\ORACLE\ORADATA\TEST\UNDOTBS01.DBF"; 
   set newname for datafile  4 to "E:\ORACLE\ORADATA\TEST\USERS01.DBF"; 
   backup as copy reuse 
   datafile  1 auxiliary format  "E:\ORACLE\ORADATA\TEST\SYSTEM01.DBF"   
   datafile  2 auxiliary format  "E:\ORACLE\ORADATA\TEST\SYSAUX01.DBF"   
   datafile  3 auxiliary format  "E:\ORACLE\ORADATA\TEST\UNDOTBS01.DBF"   
   datafile  4 auxiliary format  "E:\ORACLE\ORADATA\TEST\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:\APP\APADHI\ORADATA\AMAR\SYSTEM01.DBF 
output file name=E:\ORACLE\ORADATA\TEST\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:\APP\APADHI\ORADATA\AMAR\SYSAUX01.DBF 
output file name=E:\ORACLE\ORADATA\TEST\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:\APP\APADHI\ORADATA\AMAR\UNDOTBS01.DBF 
output file name=E:\ORACLE\ORADATA\TEST\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:\APP\APADHI\ORADATA\AMAR\USERS01.DBF 
output file name=E:\ORACLE\ORADATA\TEST\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 "TEST" RESETLOGS ARCHIVELOG  
  MAXLOGFILES     16 
  MAXLOGMEMBERS      3 
  MAXDATAFILES      100 
  MAXINSTANCES     8 
  MAXLOGHISTORY      292 
 LOGFILE 
  GROUP  1 ( 'E:\ORACLE\ORADATA\TEST\REDO01.LOG' ) SIZE 50 M  REUSE, 
  GROUP  2 ( 'E:\ORACLE\ORADATA\TEST\REDO02.LOG' ) SIZE 50 M  REUSE, 
  GROUP  3 ( 'E:\ORACLE\ORADATA\TEST\REDO03.LOG' ) SIZE 50 M  REUSE 
 DATAFILE 
  'E:\ORACLE\ORADATA\TEST\SYSTEM01.DBF' 
 CHARACTER SET AL32UTF8 

contents of Memory Script: 

   backup as copy reuse 
   archivelog like  "I:\APP\APADHI\PRODUCT\11.1.0\DB_1\RDBMS\ARC00042_0629061547.001" auxiliary format  
 "E:\ORACLE\PRODUCT\11.1.0\DB_1\RDBMS\ARC00042_0629061547.001"   archivelog like  
 "I:\APP\APADHI\FLASH_RECOVERY_AREA\AMAR\ARCHIVELOG\2007_08_02\O1_MF_1_42_3C2YJNP7_.ARC" auxiliary format  
 "E:\ORACLE\PRODUCT\11.1.0\DB_1\RDBMS\ARC00042_0629061547.001"   ; 
   catalog clone archivelog  "E:\ORACLE\PRODUCT\11.1.0\DB_1\RDBMS\ARC00042_0629061547.001"; 
   catalog clone archivelog  "E:\ORACLE\PRODUCT\11.1.0\DB_1\RDBMS\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:\ORACLE\PRODUCT\11.1.0\DB_1\RDBMS\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:\ORACLE\PRODUCT\11.1.0\DB_1\RDBMS\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:\ORACLE\PRODUCT\11.1.0\DB_1\RDBMS\ARC00042_0629061547.001 RECID=1 STAMP=629553800 

cataloged archived log 
archived log file name=E:\ORACLE\PRODUCT\11.1.0\DB_1\RDBMS\ARC00042_0629061547.001 RECID=2 STAMP=629553800 

datafile 2 switched to datafile copy 
input datafile copy RECID=1 STAMP=629553800 file name=E:\ORACLE\ORADATA\TEST\SYSAUX01.DBF 
datafile 3 switched to datafile copy 
input datafile copy RECID=2 STAMP=629553801 file name=E:\ORACLE\ORADATA\TEST\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:\ORACLE\PRODUCT\11.1.0\DB_1\RDBMS\ARC00042_0629061547.001
archived log file name=E:\ORACLE\PRODUCT\11.1.0\DB_1\RDBMS\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 "TEST" RESETLOGS ARCHIVELOG  
  MAXLOGFILES     16 
  MAXLOGMEMBERS      3 
  MAXDATAFILES      100 
  MAXINSTANCES     8 
  MAXLOGHISTORY      292 
 LOGFILE 
  GROUP  1 ( 'E:\ORACLE\ORADATA\TEST\REDO01.LOG' ) SIZE 50 M  REUSE, 
  GROUP  2 ( 'E:\ORACLE\ORADATA\TEST\REDO02.LOG' ) SIZE 50 M  REUSE, 
  GROUP  3 ( 'E:\ORACLE\ORADATA\TEST\REDO03.LOG' ) SIZE 50 M  REUSE 
 DATAFILE 
  'E:\ORACLE\ORADATA\TEST\SYSTEM01.DBF' 
 CHARACTER SET AL32UTF8 


contents of Memory Script: 

   set newname for tempfile  1 to  
 "E:\ORACLE\ORADATA\TEST\TEMP01.DBF"; 
   switch clone tempfile all; 
   catalog clone datafilecopy  "E:\ORACLE\ORADATA\TEST\SYSAUX01.DBF"; 
   catalog clone datafilecopy  "E:\ORACLE\ORADATA\TEST\UNDOTBS01.DBF"; 
   switch clone datafile all; 

executing Memory Script 

executing command: SET NEWNAME 

renamed tempfile 1 to E:\ORACLE\ORADATA\TEST\TEMP01.DBF in control file 

cataloged datafile copy 
datafile copy file name=E:\ORACLE\ORADATA\TEST\SYSAUX01.DBF RECID=1 STAMP=629553825 

cataloged datafile copy 
datafile copy file name=E:\ORACLE\ORADATA\TEST\UNDOTBS01.DBF RECID=2 STAMP=629553826 

datafile 2 switched to datafile copy 
input datafile copy RECID=1 STAMP=629553825 file name=E:\ORACLE\ORADATA\TEST\SYSAUX01.DBF 
datafile 3 switched to datafile copy 
input datafile copy RECID=2 STAMP=629553826 file name=E:\ORACLE\ORADATA\TEST\UNDOTBS01.DBF 

contents of Memory Script: 

   Alter clone database open resetlogs; 

executing Memory Script 

database opened 

contents of Memory Script: 

   catalog clone datafilecopy  "E:\ORACLE\ORADATA\TEST\USERS01.DBF"; 
   switch clone datafile  4 to datafilecopy  "E:\ORACLE\ORADATA\TEST\USERS01.DBF"; 
#online the readonly tablespace 
sql clone "alter tablespace  USERS online"; 

executing Memory Script 

cataloged datafile copy 
datafile copy file name=E:\ORACLE\ORADATA\TEST\USERS01.DBF RECID=3 STAMP=629553870 

datafile 4 switched to datafile copy 
input datafile copy RECID=3 STAMP=629553870 file name=E:\ORACLE\ORADATA\TEST\USERS01.DBF 

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


分享文章:DuplicateFromActiveDatabase
文章源于:http://njwzjz.com/article/gcoegh.html