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.
本公告的范围是讨论 Oracle 11G 中不同类型的RMAN 'duplicate database'功能
This note is only applicable for oracle 11g only. 本说明仅适用于oracle 11g
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.
您可以使用 RMAN duplicate 命令创建重复数据库。复制数据库的 DBID 与源数据库的 DBID 不同,并且完全独立运行。从11g开始,您可以通过两种方式创建复制数据库
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 通过网络将活动目标数据库复制到辅助目标位置,然后创建复制数据库。唯一的区别是您不需要具有预先存在的RMAN备份和副本。复制工作由辅助数据库执行该通道对应于辅助主机上辅助实例上的服务器会话
As part of the duplicating operation, RMAN automates the following steps: 作为复制操作的一部分,RMAN会自动执行以下步骤
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 使用 RESETLOGS 选项打开重复数据库
For the active database duplication, RMAN does one extra step .i.e. copy the target database datafiles over the network to the auxiliary instance
对于 active database duplication,RMAN会执行一个额外的步骤。即,通过网络将目标数据库数据文件复制到辅助实例。
Scope of this note is restricted to Active database duplication . For the Backup-base duplication refer Note 259694.1 Oracle10G RMAN Database Duplication.
本说明的范围仅限于 Active database duplication。有关 Backup-base duplication ,请参见 Note 259694.1 Oracle10G RMAN Database Duplication.
Basic Steps to ACTIVE database duplication: 基本步骤
1. Preparing 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 :
如果使用的是SPFILE,则重复数据库所需的唯一参数是DB_NAME。其余的其他参数可以在DUPLICATE命令本身中设置。如果不使用SPFILE,则需要设置初始化参数以在初始化参数文件中进行设置。必需的参数是
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:
为了简单起见,在此公告中,我们在pfile中指定了所有必需的参数。例如
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 创建辅助实例的Oracle密码文件
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 必须输入密码文件。基于备份的 duplication 不需要密码文件。对于 Active database duplication ,它使用与目标数据库相同的SYSDBA密码的密码文件直接连接到辅助实例。如果要使用密码文件,请确保与目标数据库具有相同的SYSDBA密码。此外,您还可以在DUPLICATE命令上指定 PASSWORD FILE 选项。在这种情况下,RMAN将源数据库密码文件复制到目标主机并覆盖任何辅助实例的现有密码文件。
In this bulletin we are using password file option in the duplicate command. 在此公告中,我们在 duplicate 命令中使用密码文件选项
Create the database service (only for windows) and password file. For example :
创建数据库服务(仅适用于Windows)和密码文件。例如 :
% 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. 对于Unix/Linux,不需要服务,仅需要密码文件
1.3 Start the Auxiliary instance in NOMOUNT. For example : 在NOMOUNT中启动辅助实例。例如
% 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. 创建必要的oracle NET连接
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 :
在辅助服务器上的listener.ora文件中为辅助服务器插入静态条目。此外,目标和辅助目录中都需要tnsnames.ora条目。例如
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: 检查目标实例和辅助实例之间的连接性
Execute on the TARGET and AUXILIARY host % tnsping <target database> % tnsping <auxiliary database>
3. Start RMAN and Connect to the Database Instances 启动RMAN并连接到数据库实例
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. --启动RMAN并以TARGET的身份连接到源数据库,复制数据库的实例以AUXILIARY的形式连接到恢复目录数据库(如果适用),并连接恢复目录数据库。您可以在任何主机上启动RMAN客户端,只要它可以连接到所有数据库实例即可。如果辅助实例需要基于文本的初始化参数文件,则该文件必须存在于运行RMAN客户端应用程序的同一主机上。
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/<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: 运行DUPLICATE数据库命令
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 :
最简单的情况是使用 active database duplication 将数据库复制到其他主机并使用不同的目录结构。请看以下示例:
This example assumes
This example assumes the following: 本示例假定以下内容
* Using a recovery catalog. 使用恢复目录
* The target database is on host1 and contains 4 datafiles. 目标数据库位于host1上,并包含4个数据文件
* Duplicate the target to a database on the different host having different file structure. 将目标复制到具有不同文件结构的不同主机上的数据库
* Tablespace USERS in target is read-only tablespace. 目标中的表空间USERS是只读表空间
* Running duplicate database from the Auxiliary site. 从辅助站点运行duplicate database
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: 这是怎么回事
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