< meta name="robots" content="all" scheme="http://www.robotstxt.org/">
  • Skip Headers

    Oracle® Database Backup and Recovery Advanced Use r's Guide
    10g Release 1 (10.1)

    Part Number B10734-01
    Go to Documentation Home
    Home
    Go to Book List
    Book List
    G
o to Table of Contents
    Contents
    Go to Index
    Index
    Go to Master Index
    < font size="-2">Master Index
    Go to Feedback page
    Feedback

    Go to previous page
    Previous
    Go to next page
    Next
    View PDF

    11
    Duplicating a Da tabase with Recovery Manager

    This chapter describes how to us e the DUPLICATE command to create a duplicate database for testing purposes. This chapter contains these topics:

    Creating a Duplicate Dat abase: Overview

    You can use the RMAN DUPLICATE comm and to create a duplicate database from target database backups while still retaining the origi nal target database. The duplicate database can be identical to the original database or contain only a subset of the original tables paces.

    A duplicate database is a copy of a target database that you can run independently f or a variety of purposes. For example, you can use it to:

    For example, you can duplicate the production database on host1 to host2, and then use the dupli cate database on host2 to practice restore and recovery scenarios while the production database on host1 co ntinues as usual.

    A duplicate database is distinct from a standby database, although both t ypes of databases are created with the DUPLICATE command. A standby database is a copy of the primary database that you can update continually or periodically with archived logs from the primary database. If the primary database is damaged or destroyed, then you can perform failover to the standby database and effectively transform it into the new primary database. A duplicate databa se, on the other hand, cannot be used in this way: it is not intended for failover scenarios and does not sup port the various standby recovery and failover options.

    See Also:

    Oracle Data Guard Concepts and Administration to learn how to create a standby database w ith the DUPLICATE command

    How Recovery Manager Duplicates a Database

    To prepare for database duplication, you must first create an auxiliary ins tance as described in "Preparing the Auxiliary Instance for Duplication: Basic Steps". For the duplication to work, you must connect RMAN to both the target (primary) database and an auxi liary instance started in NOMOUNT mode.

    You must have at least one auxiliary c hannel allocated on the auxiliary instance. The principal work of the duplication is performed by the auxiliary channel, which starts a server session on the duplicate host. This channel then restores the necessary backups of the primary database, uses them to creat e the duplicate database, and initiates recovery.

    So long as RMAN is able to connect to the primary and auxiliary instances, the RMAN client can run on any machine. However, all backups and archived logs used for creating an d recovering the duplicate database must be accessible by the server session on the duplicate host. If the duplicate host is not the same as the primary host, then you must make backups on disk on the primary host available to the duplicate host with the same full p ath name as in the primary database. When using disk backups, you can accomplish this goal in any of the following ways:

    When using tape backups, you must make the tapes containing the backups accessible to th e remote node, either by physically moving the tape to the remote host or by means of a network tape server.

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

    During duplication, RMAN must perform incomplete recovery because the online redo logs in the target are not backed up and cannot be applied to the duplicate data base. The farthest that RMAN can go in recovery of the duplicate database is the most recent redo log archived by the target database .

    See Also:

    Oracle Data Guard C oncepts and Administration to learn how to create a standby database with RMAN

    Database Duplication Options

    When duplicating a database, you have the following options:

    • You can run the DUPLICATE command with or without a recov ery catalog
    • You can skip read-only tablespaces with the SKIP READONLY clause. Read-only tablespaces are included by default. If you omit them, then you can add them later.
    • You can exclude tablespaces from the duplicate database with the SKIP TA BLESPACE clause. You can exclude any tablespace except the SYSTEM tablespace or tablespaces containing rollback o r undo segments.
    • You can create the duplicate database in a new host. If the d irectory structure is the same on the new host, then you can specify the NOFILENAMECHECK option and reuse the target dat afile filenames for the duplicate datafiles.
    • You can duplicate a target databa se on a traditional file system to an ASM or Oracle Managed Files location.
    • Yo u can recover the duplicate database to a past point in time, using use the SET UNTIL command or DUPL ICATE ... UNTIL command. By default, the DUPLICATE command creates the duplicate databa se by using the most recent backups of the target database and then performs recovery to the most recent consistent point contained i n the incremental backups and archived logs.
    • You can register the duplicate da tabase in the same recovery catalog as the target database. This option is possible because RMAN gives the duplicate database a new, unique DBID during duplication.


      Note:

      If you copy the target database by means of operating system utilities, then the DBID of the copied database remains the same as the original database. To register the copy database in the same recovery catalog wi th the original, you must change the DBID with the DBNEWID utility (refer to Oracle Database Utilities).


    • In some cases, you can set the duplicate database DB_NAME differently from the target database DB_NAME. More specifically, if the duplicate database exists in the same Oracle home as the target, then the DB_NAME initialization parameter must be different. If the duplicate database is in a different Oracle home from the target database, th en the DB_NAME setting for the duplicate database must be unique among databases in its Oracle home. This is true whethe r or not the duplicate database is on the same host as the target.

    Duplicating a Database: Prerequisites and Restrictions

    RMAN duplication involves a number of prerequisites, restrictions, and caveats. Re view the restrictions section of the DUPLICATE command in the Oracle Database Recovery Manager Reference for a complete list.

    Gener ating Files for the Duplicate Database

    When duplicating a databa se, RMAN creates the required database files. This section describes these stages of file creation:

    Creating the Duplicate Co ntrol Files

    The DUPLICATE command creates the control f iles by using the names listed in the initialization parameter file of the auxiliary instance. When choosing names for the duplicate database control files, make sure that you set the initialization parameter settings correctly so that you do not overwrite the produ ction files at the target database.

    Creating the Duplicate Online Redo Logs

    < a href="rcmdupdb.htm#1006247">Table 11-1 lists the options for creating the names of the duplicate online redo logs. The opt ions appear in the order of precedence.

    Table 11-1 Order of Precedence for Online Redo Log Filename Creation
    < tr class="Formal">
    Order Method Result

    1

    Specify the LOGFILE clause of DUPLICATE command.

    Creates online redo logs as specified.

    2

    Set LOG_FILE_NAME_CONVERT initialization parameter.

    Transfor ms target filenames, for example, from log_* to duplog_*. Note that you can specify multiple conversion pai rs.

    This parameter allows the redo log to exist as long as the size matches, because it uses the REUSE parameter when creating the logs.

    3

    Do none of the precedin g steps.

    Makes the duplicate filenames the same as the target filen ames. You must specify the NOFILENAMECHECK option when using this method and the duplicate database should be in a diffe rent host.

    The order of precedence determines how RMAN renames th e online redo logs. For example, if you specify both the LOGFILE clause and the LOG_FILE_NAME_CONVERT param eter, then RMAN uses the LOGFILE clause. If you specify neither of the first two options, then RMAN uses the original ta rget redo log filenames for the duplicate database files.


    Caution:

    If the target and duplicate databases are in the same host, then do not use the name of an online redo log currently in use by the target database. Also, do not use the name of an online log currently in use by the target database if the duplicate database is in a different host and NOFILENAMECHECK is not used.


    Renaming Datafiles When Duplicating a Database

    There are several methods of specifying new names to be used for the datafiles of your duplicate database. Listed in order of p recedence, they are:

    • Use the SET NEWNAME command, within a RUN block enclosing both the SET NEWNAME commands and the DUPLICATE command.
    • Use the CONFIGURE AUXNAME command to specify new names for existing datafiles, before using the DUPLICATE command.
    • Specify the DB_FILE_NAME_CONV ERT parameter to the DUPLICATE command, to specify a rule for converting filenames for any datafiles not renamed using SET NEWNAME or CONFIGURE AUXNAME. Note that you can specify multiple conversion pairs, and use ASM di sk groups.
    • Set the DB_FILE_NAME_CONVERT initialization parameter, subject to the same semantics and limitations as the DB_FILE_NAME_CONVERT parameter to the DUPLICATE comma nd.

    If yo do not use any of these options, then the duplicate database will reuse the original datafile filenames from the target database.

    Preventing Filename Checking

    It is possible for CONFIGURE AUXNAME, SET NEWNAME, or DB_FILE_NAME_C ONVERT to generate a name that is already in use in the target database. In this case, specify NOFILENAMECHECK to avoid an error message. For example, assume that the host A database has two files: datafile 1 is named /oracle/d ata/file1.f and datafile 2 is named /oracle/data/file2.f. When duplicating to host B, you use a conf igured channel to duplicate as follows:

    RUN
    {
    
     SET NEWNAME FOR DATAFILE 1 TO /oracle/data/file2.f; # rename df 1 as file2.f
      SET NEWNAME FOR DATAFILE 2 TO /
    oracle/data/file1.f; # rename df 2 as file1.f
      DUPLICATE TARGET DATABASE TO newdb;
    } 
    
    

    Even though you issued SET NEWNAME comman ds for all the datafiles, the DUPLICATE command fails because the duplicate filenames are still in use in the target dat abase. Although datafile 1 in the target is not using /oracle/data/file2.f, and datafile 2 in the target is not using /oracle/data/file1.f, the target filename is used by one of the duplicate datafiles and so you m ust specify NOFILENAMECHECK to avoid an error.

    Skipping Read-Only Tablespaces When Duplicating a Database

    When you specify SKIP READONLY, RMAN does not duplicate the dataf iles of read-only tablespaces. After duplication is complete, you can query the views in the duplicate database described in Table 11-2 and Table 11-3 to determine which datafiles were s kipped. The STATUS and ENABLED columns are the key to determining the current status of the duplicate dataf ile.

    Table 11-2 Read-Only Tablespaces in V$DATAFILE View on Duplicate Database
    In the colu mn ... The value is ...

    STATUS

    OFFLINE

    ENABLED

    READ ONLY

    NAME< /code>

    MISSINGxxx

    T able 11-3 Read-Only Tablespaces in Data Dictionary Views on Duplicate Database
    View In the column ... The value is ...

    DBA_DATA_FILES

    STATUS

    AVAILA BLE

    DBA_TABLESPACES

    STATUS

    READ ONLY

    Skipping OFFLINE NORMAL Tablespaces When Duplicati ng a Database

    When tablespaces are taken offline with the OFFL INE NORMAL option before a DUPLICATE operation, RMAN does not duplicate the datafiles of these table spaces. After duplication, you can manually add or drop these tablespaces. Query the views in the duplicate database described in Table 11-4 and Table 11-5 to determine which datafiles a re offline, based on the STATUS and ENABLED columns.

    Table 11-4 Offline Tablespaces in V$ Views on Duplicate Database
    < /a> In the column ... The value is ...

    STATU S

    OFFLINE

    ENABLED

    DISABLED

    NAME

    MIS SINGxxx

    Table 11-5 Offline Tablespaces in Data Dictionary Views on Duplicate Database< /font>
    View In the column ... The value is ...

    DBA_ DATA_FILES

    STATUS

    < a name="1006445">

    AVAILABLE

    DBA_TABLESPACES

    STATUS

    OFFLINE

    When you take a tablespace offline with the IMMEDIATE option, RMAN dupli cates rather than skips the tablespace because this tablespace requires recovery. As with online tablespaces, RMAN requires a valid b ackup for duplication.

    Preparing the Auxiliary Instance for Duplication: Basic Steps

    Perform these tasks before performing RMAN duplication: