A duplicate
database is a copy of the target database (or a subset of the target
database) with a new, unique database identifier (DBID). The target database
site and duplicate database site can be on the same host or separate hosts. The
duplicate database is created using backups and archived redo log files from
the target database.
You can
operate it independently of the target database to:
•
Test
backup and recovery procedures
•
Recover
objects that were inadvertently dropped from the target database by creating an
export containing the objects in the duplicate database and importing them into
the production database
Creating
a Duplicate Database
1. Create an Oracle password file for
the auxiliary instance.
2. Establish Oracle Net connectivity to
the auxiliary instance.
3. Create an initialization parameter
file for the auxiliary instance.
4. Start the auxiliary instance in
NOMOUNT mode.
5. Mount or open the target database.
6. Ensure that backups and archived
redo log files are available.
7. Allocate auxiliary channels if
needed.
8. Execute the DUPLICATE command.
Creating
an Initialization Parameter File for the Auxiliary Instance
You must
create a text initialization parameter file for the auxiliary instance. The
text initialization parameter file must reside on the same host as the RMAN
client that you use to execute the DUPLICATE command.
Take note
of the requirements for each of the following parameters:
•
DB_NAME: If the target database and the
duplicate database are in the same Oracle home, you must set DB_NAME to a
different name. If they are in different Oracle homes, you must ensure that the
name of the duplicate database differs from the other names in its Oracle home.
Be sure to use the same database name that you set for this parameter when you
execute the DUPLICATE command.
•
DB_BLOCK_SIZE: The block size of the auxiliary
database must match the block size of the target database. Specify the same
value in the initialization parameter file for the auxiliary database as set in
the initialization parameter file for the target database. If the parameter is
not set in the initialization parameter file for the target database, do not
set it in the auxiliary instance initialization parameter file.
In
addition, be sure to verify the settings of all initialization parameters that
specify path names. Verify that all specified paths are accessible on the
duplicate database host.
Specifying
Parameters for Control File Naming
RMAN
generates names for the required database files when you execute the DUPLICATE
command. You can control the naming of the files by specifying the following
initialization parameters in the auxiliary instance initialization parameter
file:
•
CONTROL_FILES: Specify the names of the control
files in this parameter. If you do not set the names via this parameter, the
Oracle server creates an Oracle-managed control file in a default control
destination. Refer to the SQL CREATE CONTROLFILE command in the SQL Reference
manual for specific information.
•
DB_FILE_NAME_CONVERT: This parameter is used to specify
the names of data files for the auxiliary database. It has the format
DB_FILE_NAME_CONVERT = 'string1' , 'string2', where string1
is the pattern of the target database file name and string2 is the
pattern of the auxiliary database file name. You can also specify the
DB_FILE_NAME_CONVERT parameter as an option to the DUPLICATE DATABASE command.
•
LOG_FILE_NAME_CONVERT: This parameter is used to specify
the names of the redo log files for the auxiliary database. It has the format
LOG_FILE_NAME_CONVERT = 'string1' , 'string2', where string1
is the pattern of the target database file name and string2 is the
pattern of the auxiliary database file name. You can also use the LOGFILE
clause of the DUPLICATE DATABASE command to specify redo log file names.
As an
alternative to using the initialization parameters to control the naming of the
files, you can use the following techniques to rename the redo log files:
•
Use
the LOGFILE clause of the DUPLICATE command.
•
Set
the Oracle Managed Files initialization parameters: DB_CREATE_FILE_DEST,
DB_CREATE_ONLINE_DEST_n, or DB_RECOVERY_FILE_DEST.
You can use
the following techniques to specify new names for data files:
•
Include
the SET NEWNAME FOR DATAFILE command within a RUN block to specify new names
for the data files.
•
Use
the CONFIGURE AUXNAME command.
•
Specify
the DB_FILE_NAME_CONVERT parameter with the DUPLICATE command.
CONTROL_FILES='/u01/app/oracle/oradata/aux/control01.ctl',
'/u01/app/oracle/oradata/aux/control02.ctl',
'/u01/app/oracle/oradata/aux/control03.ctl'
DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/orcl',
'/u01/app/oracle/oradata/aux'
LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/orcl',
'/u01/app/oracle/oradata/aux'
Starting
the Instance in NOMOUNT Mode
•
After
you have created the text initialization parameter file, invoke SQL*Plus to
start the auxiliary instance in NOMOUNT mode.
•
After
you invoke SQL*Plus, create a server parameter file (SPFILE) from your text
initialization parameter file. You can execute the CREATE SPFILE before or
after you have started the instance. You should create the SPFILE in the
default location so that you do not need to specify the PFILE option with the
DUPLICATE command. RMAN shuts down the auxiliary instance and restarts it as
part of the duplication process, so you must specify the PFILE option if you do
not use an SPFILE.
startup
nomount pfile='$HOME/auxinstance/initAUX.ora'
create
spfile from pfile='$HOME/auxinstance/initAUX.ora';
Ensuring
That Backups and Archived Redo Log Files Are Available
•
Backups
of all target database data files must be accessible on the duplicate host.
•
Backups
can be a combination of full and incremental backups.
•
Archived
redo log files needed to recover the duplicate database must be accessible on
the duplicate host.
•
Archived
redo log files can be:
•
Backups
on a media manager
•
Image
copies
•
Actual
archived redo log files
The backups
needed to restore the data files must be accessible on the duplicate host. You
do not need a whole database backup. RMAN can use a combination of full and
incremental backups of individual data files during the duplication process.
Archived
redo logs required to recover the duplicate database to the desired point in
time must also be accessible. The archived redo log files can be backups, image
copies, or the actual archived redo logs. The backups or copies can be
transferred to the local disk of the duplicate database node or mounted across
a network by some means such as network file system (NFS).
Allocating
Auxiliary Channels
If you do
not have automatic channels configured, manually allocate at least one
auxiliary channel before issuing the DUPLICATE command. The ALLOCATE AUXILIARY
CHANNEL command must be within the same RUN block as the DUPLICATE command. The
channel type specified on the ALLOCATE AUXILIARY CHANNEL command must match the
media where the backups of the target database are located. If the backups
reside on disk, you can allocate more than one channel to reduce the time it
takes for the duplication process. For tape backups, you can specify the number
of channels that correspond to the number of devices available.
•
Auxiliary
channels specify a connection between RMAN and an auxiliary database instance.
•
If
automatic channels are not configured, allocate auxiliary channels:
•
Start
RMAN with a connection to the target database, the auxiliary instance, and
recovery catalog if applicable.
•
Allocate
at least one auxiliary channel within the RUN block.
$
rman target sys/oracle@trgt auxiliary sys/oracle@aux
RMAN>
RUN
{ALLOCATE AUXILIARY CHANNEL aux1 DEVICE
TYPE DISK;
ALLOCATE AUXILIARY CHANNEL aux2 DEVICE
TYPE DISK;
…
Using
the RMAN DUPLICATE command
Invoke RMAN
and connect to the target database and auxiliary instance before issuing the
DUPLICATE command. The auxiliary instance must be started with the NOMOUNT
option and the target database must be mounted or open.
•
Connect
to the target database and the auxiliary instance.
•
Specify
the same database name that you used in the DB_NAME initialization parameter.
RMAN>
RUN
{ALLOCATE AUXILIARY CHANNEL aux1 DEVICE
TYPE DISK;
ALLOCATE AUXILIARY CHANNEL aux2 DEVICE
TYPE DISK;
...
DUPLICATE TARGET DATABASE to auxdb;
}
Understanding
the RMAN Duplication Operation
When you
execute the DUPLICATE command, RMAN performs the following operations:
•
Creates
a control file for the duplicate database
•
Restores
the target data files to the duplicate database
•
Performs
incomplete recovery using all available incremental backups and archived redo
log files
•
Shuts
down and restarts the auxiliary instance
•
Opens
the duplicate database with the RESETLOGS option
•
Creates
the online redo log files
•
Generates
a new, unique DBID for the duplicate database
Options
for the DUPLICATE Command
Specify
additional options when executing the DUPLICATE command as appropriate.
•
SKIP
READONLY: Use to
exclude read-only tablespace data files.
•
SKIP
TABLESPACE: Use to
exclude tablespaces from the target database. You cannot exclude the SYSTEM
tablespace or tablespaces containing undo or rollback segments.
•
NOFILENAMECHECK: Use to prevent RMAN from checking
whether target database data files with the same name as duplicate database
data files are in use. You must specify this option when the target database
and duplicate database data files and redo log files use the same names. You
would typically use this when you create a duplicate database on a host that
has the same disk configuration, directory structure, and file names as the
target database host. If you do not specify NOFILENAMECHECK in this situation,
RMAN returns an error.
•
OPEN
RESTRICTED: Use to
enable RESTRICTED SESSION automatically after the database is opened.