This chapter explains advanced forms of database duplication that are not covered in Duplicating a Database.
This chapter contains the following topics:
"Step 2: Choosing a Strategy for Naming Duplicate Files" explains the recommended strategy of using the same names for the duplicate and source database files. In all other cases, you must choose an alternative naming strategy for the duplicate files. The strategy that you use depends on whether the source and duplicate databases use Oracle Managed Files (OMF) or Oracle Automatic Storage Management (ASM).
If the source data files use OMF, then you cannot rename them using DB_FILE_NAME_CONVERT
. "Using Non-ASM Storage " discusses the details and options of OMF-managed data files.
This section contains the following topics:
This section explains how to specify names for the duplicate files when the following condition is true:
The source and auxiliary hosts either use different directory structures or use the same structure but you want to name the duplicate files differently.
Table 26-1 summarizes the formats available for naming each type of file.
This section contains the following topics:
As shown in Table 26-1, one way to name duplicate data files is to use the SET NEWNAME
command before executing the DUPLICATE
command. RMAN supports the following commands, listed in order of precedence:
SET NEWNAME FOR DATAFILE
and SET NEWNAME FOR TEMPFILE
SET NEWNAME FOR TABLESPACE
SET NEWNAME FOR DATABASE
The order of precedence means that SET NEWNAME FOR TABLESPACE
specifies names for files not named by SET NEWNAME FOR DATAFILE
and SET NEWNAME FOR TEMPFILE,
whereas SET NEWNAME FOR DATABASE
specifies names for files not named by SET NEWNAME FOR TABLESPACE
, SET NEWNAME FOR DATAFILE
, or SET NEWNAME FOR TEMPFILE
.
When using SET NEWNAME FOR DATAFILE
, you can specify a full path as a literal, as in /oradata1/system01.dbf
. When using SET
with FOR DATABASE
or FOR TABLESPACE
, however, you must use at least one of these substitution variables described in Table 26-1: %b
, %f
, %U
. (%I
and %N
are optional.)
Table 26-1 Substitution Variables for SET NEWNAME
Variable | Description |
---|---|
Specifies the file name stripped of directory paths. For example, if a data file is named |
|
Specifies the absolute file number of the data file for which the new name is generated. For example, if data file |
|
Specifies the DBID. |
|
Specifies the tablespace name. |
|
Specifies the following format: |
To use SET NEWNAME to specify new file names:
Assume the following:
DBID
is 87650928
Database name is PROD
Table 26-2 shows the results from previous example.
Table 26-2 Results from SET NEWNAME FOR DATABASE Command
Before SET NEWNAME DATABASE | Tablespace Name | Data File Number | After SET NEWNAME DATABASE TO '/oradata/%U'; |
---|---|---|---|
|
|
1 |
|
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
1 |
|
See Also:
Oracle Database Backup and Recovery Reference for details on substitution variables usable in SET
NEWNAME
The CONFIGURE AUXNAME
command is an alternative to the SET NEWNAME
command. The difference is that after you configure the auxiliary name the first time, additional DUPLICATE
commands reuse the configured settings. In contrast, you must reissue the SET NEWNAME
command every time you execute the DUPLICATE
command.
To use CONFIGURE AUXNAME to specify names for duplicate data files:
See Also:
Oracle Database Backup and Recovery Reference for details on using CONFIGURE
AUXNAME
The following sections discuss requirements for creating a duplicate database when some or all files of the duplicate database use OMF or ASM.
See Also:
Oracle Automatic Storage Management Administrator's Guide for an introduction to ASM and OMF
This section contains the following topics:
When creating a duplicate database that uses Oracle Managed Files, you must set initialization parameters in the auxiliary instance. If you use the SPFILE
clause of DUPLICATE
to name the files, then you can set initialization parameters in the SPFILE
clause. Table 26-3 describes the relevant parameters and recommended settings and Table 26-4 lists the restrictions on setting other initialization parameters
See:
Oracle Database Reference for more information about these parameters.
Table 26-3 Initialization Parameters for Oracle Managed Files
Initialization Parameter | Purpose | Recommendation |
---|---|---|
Specifies the default location for Oracle managed data files. This location is also the default location for Oracle managed control files and online logs if no |
Set this parameter to the location for the Oracle Managed Files. Any database files for which no other location is specified are created in |
|
Specifies the default location for Oracle managed control files and online redo logs. If multiple parameters are set, then one control file and one online redo log is created in each location. |
Set these parameters ( |
|
Specifies the default location for the fast recovery area. The fast recovery area contains multiplexed copies of current control files and online redo log files. |
Set this parameter if you want a multiplexed copy of the control file and online redo log file in the recovery area. |
Table 26-4 Initialization Parameter Restrictions for Oracle Managed Files
Initialization Parameter | Purpose | Restriction |
---|---|---|
Specifies one or more names of control files, separated by commas. |
Do not set this parameter if you want the duplicate database control files in an OMF format. Oracle recommends that you use a server parameter file at the duplicate database when using control files in an OMF format. |
|
Converts the file name of a new data file on the primary database to a file name on the duplicate database. |
Do not set this parameter. Omitting this parameter enables the database to generate valid Oracle managed file names for the duplicate data files. |
|
Converts the file name of a new log file on the primary database to the file name of a log file on the standby database. |
Do not set this parameter. Omitting this parameter allows the database to generate valid Oracle managed online redo log file names. To direct duplicate database online redo log files to Oracle managed storage, you can use the |
The procedure for creating a duplicate database to an ASM location is similar to the procedure described in "Settings and Restrictions for OMF Initialization Parameters ". The difference is that you must identify the initialization parameters that control the location where files are created and set these parameters to an ASM disk group. For example, set DB_CREATE_FILE_DEST
, DB_CREATE_ONLINE_DEST_
n
, and CONTROL_FILES
to +DISK1
.
In this example, you use active database duplication. If the source database uses a server parameter file (or a backup is available), then you can create a temporary initialization parameter file on the destination host and set only the DB_NAME
parameter.
Assume that the source database prod
is on host1
and stores its data files in a non-ASM file system. The control files for prod
are located in /oracle/oradata/prod/
. You want to duplicate the source database to database dupdb
on remote host host2
. You want to store the duplicate database files in ASM disk group +DISK1
.
After connecting RMAN to the target, duplicate, and recovery catalog databases, run the RMAN script shown in Example 26-1 to duplicate the database.
Example 26-1 Duplicating from a File System to ASM (Active)
DUPLICATE TARGET DATABASE TO dupdb FROM ACTIVE DATABASE SPFILE PARAMETER_VALUE_CONVERT '/oracle/oradata/prod/', '+DISK1' SET DB_CREATE_FILE_DEST +DISK1;
When the DUPLICATE
command completes, the duplicate database is created, with data files, online redo log files, and control files in ASM disk group +DISK1
.
In this example, you use active database duplication. If the source database uses a server parameter file (or a backup is available), then you can create a temporary initialization parameter file on the destination host and set only the DB_NAME
parameter.
Assume that the source database prod
is on host1
and stores its data files in ASM disk group +DISK1
. You want to duplicate the target to database dupdb
on remote host host2
. You want to store the data files for dupdb
in ASM. Specifically, you want to store the data files and control files in disk group +DISK2
.
In the DUPLICATE
command, set PARAMETER_VALUE_CONVERT
to convert all directory locations from +DISK1
to +DISK2
. The new file names in +DISK2
are generated by ASM and do not match the original file names in disk group +DISK1
.
After connecting to the target, duplicate, and catalog databases, run the RMAN script shown in Example 26-2 to duplicate the database.
Example 26-2 Duplicating from ASM to ASM (Active)
DUPLICATE TARGET DATABASE TO dupdb FROM ACTIVE DATABASE SPFILE PARAMETER_VALUE_CONVERT '+DISK1','+DISK2' SET DB_RECOVERY_FILE_DEST_SIZE='750G';
When the DUPLICATE
command completes, the duplicate database is created, with data files, online redo logs, and control files in the larger ASM disk group +DISK2
.
To name Oracle managed data files, you can use the same SET NEWNAME
commands described in "Using SET NEWNAME to Name File System Data Files and Temp Files", but with TO NEW
instead of TO '
filename
'
. RMAN creates the specified data files or temp files with Oracle Managed File names in the location specified by DB_CREATE_FILE_DEST
.
To use SET NEWNAME to specify names for Oracle Managed Files:
See Also:
Oracle Database Backup and Recovery Reference for details on using SET
NEWNAME
Another technique to generate names besides using SET NEWNAME
or CONFIGURE AUXNAME
commands is to use DB_FILE_NAME_CONVERT
to transform target file names. For example, you can change the target file name from /oracle/
to /dup/oracle/
. DB_FILE_NAME_CONVERT
allows you to specify multiple conversion file name pairs. It can also be used to produce names for data files and temp files.
You can specify DB_FILE_NAME_CONVERT
in the DUPLICATE
command or you can set it in the initialization parameter of the auxiliary instance.
You cannot use the DB_FILE_NAME_CONVERT
clause of the DUPLICATE
command to control generation of new names for files at the duplicate instance that are in the Oracle Managed Files (OMF) format at the source database instance. See Oracle Database Backup and Recovery Reference for details on this restriction.
If the LOG_FILE
clause has been omitted and no Oracle Managed Files initialization parameters DB_CREATE_FILE_DEST
, DB_CREATE_ONLINE_DEST_n
, or DB_RECOVERY_FILE_DEST
are specified, then LOG_FILE_NAME_CONVERT
can transform target file names. This works in much the same way as the DB_FILE_NAME_CONVERT
and can transform target file names from log_*
to duplog_*
. You can specify multiple conversion file name pairs with this parameter.
When you specify LOG_FILE_NAME_CONVERT
, RMAN uses the REUSE
parameter when creating the online redo logs. If an online redo log file exists at the named location and is of the correct size, then it is reused for the duplicate.
Do not specify LOG_FILE_NAME_CONVERT
if you set Oracle Managed Files initialization parameters.
LOG_FILE_NAME_CONVERT
cannot be specified as a DUPLICATE
clause, it can only be specified in the initialization parameter of the auxiliary instance.
You cannot use the LOG_FILE_NAME_CONVERT
initialization parameter to control generation of new names for files at the duplicate instance that are in the Oracle Managed Files (OMF) format at the source database instance.
"Step 4: Making Backups Accessible to the Duplicate Instance" recommends using the shared disk technique to make backups available to the auxiliary instance. When NFS or shared disk is not an option, then the path that stores the backups must exist on both the source and destination hosts unless the BACKUP LOCATION
option is used for the DUPLICATE command without a target or recovery catalog connection.
Assume that you maintain two hosts, srchost
and dsthost
. The database on srchost
is srcdb
. The RMAN backups of srcdb
reside in /dsk1/bkp
on host srchost
. The directory /dsk1/bkp
is in use on the destination host, so you intend to store backups in /dsk2/dup
on the destination host.
To transfer the backups from the source host to the destination host:
The auxiliary channel can search for backups in /dsk2/dup
on the destination host and restore them.
The procedure in "Step 7: Creating an Initialization Parameter File and Starting the Auxiliary Instance" assumes that you use the SPFILE
clause of the DUPLICATE
command. If the source database does not use a server parameter file, then you must set all necessary parameters for the auxiliary instance in a text-based initialization parameter file.
Table 26-5 describes a subset of the possible initialization parameters. See Oracle Database Reference provides more information about these parameters. See Table 26-1 to learn about options for naming duplicate files.
Table 26-5 Auxiliary Instance Initialization Parameters
Initialization Parameter | Value | Status |
---|---|---|
The same name used in the The |
Required |
|
Control file locations |
Required |
|
The block size for the duplicate database. This block size must match the block size of the source database. If the source database parameter file contains a value for the |
Required if this initialization parameter is set in the source database |
|
Pairs of strings for converting the names of data files and temp files. You can also specify |
Optional |
|
Pairs of strings for naming online redo log files. See "Using LOG_FILE_NAME_CONVERT to Generate Names for Non-OMF or ASM Log Files". |
Optional |
|
Location for Oracle managed data files. |
Optional |
|
Location for Oracle managed online redo log files |
Optional |
|
Location for fast recovery area |
Optional |
|
Oracle Real Application Cluster (Oracle RAC) parameters:
|
Set these parameters for each instance of the Oracle RAC database. |
Required for Oracle RAC configuration |
To create an initialization parameter file when not planning to use the SPFILE clause:
"Step 7: Creating an Initialization Parameter File and Starting the Auxiliary Instance" assumes that the source database instance uses a server parameter file. This scenario assumes that the source database does not currently use a server parameter file or RMAN cannot restore a backup server parameter file. In this case, you must start the auxiliary instance with a text-based initialization parameter file.
To start the auxiliary instance in preparation for database duplication:
It is not always necessary to duplicate all tablespaces of a database. For example, you may plan to generate reports that require only a subset of tablespaces from your source database.
Note:
When excluding tablespaces in backup-based duplication without a target connection or without a target and a recovery catalog connection, RMAN has special prerequisites. See the Prerequisites section of the DUPLICATE
entry in Oracle Database Backup and Recovery Reference for details.
Table 26-6 explains DUPLICATE
command options for specifying subsets of tablespaces for the duplicate database.
Table 26-6 Options to Specify Subsets of Tablespaces for the Duplicate Database
DUPLICATE Options | Explanation |
---|---|
|
Excludes the data files of read-only tablespaces from the duplicate database |
|
Excludes the specified tablespaces from the duplicate database. You cannot exclude the |
|
Automatically includes the |
To specify a subset of tablespaces for a duplicate database:
DUPLICATE
command with one or more of the options in Table 26-6.Other factors that influence what tablespaces are copied include the OFFLINE NORMAL
option. When tablespaces are taken offline with the OFFLINE NORMAL
option before duplication, RMAN does not duplicate the associated data files, and issues DROP TABLESPACE
statement for these tablespaces on the duplicate database. Therefore, you do not have to specify options to exclude these tablespaces.
Note:
RMAN does duplicate tablespaces that are taken offline with any other option besides NORMAL
(unless they are named in a SKIP TABLESPACE
option). Only OFFLINE NORMAL
tablespaces are skipped automatically. As with online tablespaces, RMAN requires a valid backup for these tablespaces when you use backup-based duplication.
Example 26-3 Excluding Read-Only Tablespaces
This example shows how to skip read-only tablespaces.
DUPLICATE TARGET DATABASE TO dupdb FROM ACTIVE DATABASE SKIP READONLY NOFILENAMECHECK;
Example 26-4 Excluding Specified Tablespaces
This example shows how to skip a tablespace named tools
.
DUPLICATE TARGET DATABASE TO dupdb FROM ACTIVE DATABASE SKIP TABLESPACE tools NOFILENAMECHECK;
You can use the TABLESPACE
option to specify which tablespaces to include in the specified database. Unlike the SKIP TABLESPACE
option, which specifies which tablespaces to exclude from the duplicate database, this option specifies which tablespaces to include and then skips the remaining tablespaces. The duplicated subset of tablespaces must be self-contained. The resulting set of skipped tablespaces must not have undo segments or materialized views.
Example 26-5 Including Specified Tablespaces
This example is a variation of Example 25-1 except with the users
tablespace included, which is assumed to be self-contained, and all other tablespaces excluded, except for SYSTEM
and SYSAUX
tablespaces and tablespaces with undo segments.
DUPLICATE TARGET DATABASE TO dupdb FROM ACTIVE DATABASE TABLESPACE users NOFILENAMECHECK;
Assume that you perform backup-based duplication with a target connection, but no recovery catalog connection. Assume that you want to specify a subset of tablespaces for duplication. If the target database is not open in this scenario, then RMAN has no way to obtain the names of the tablespaces with undo segments. Thus, you must specify the UNDO TABLESPACE
option for these tablespaces as shown in Example 26-6.
Example 26-6 Including Specified Tablespaces
DUPLICATE TARGET DATABASE TO dupdb TABLESPACE users UNDO TABLESPACE undotbs NOFILENAMECHECK;