database creation from rman backup
database creation from rman backup
RMAN has the ability to duplicate, or clone, a database from a backup or from an active database. It
is possible to create a duplicate database on a remote server with the same file structure, a remote
server will a different file structure or the local server with a different file structure.
The article assumes the duplicate database is being created on a separate server, using the same
SID (DB11G) and the same file structure as the source database. Explanations of several other
scenarios are available here.
Backup-Based Duplication
Create a backup of the source database, if a suitable one doesn't already exist.
$ rman target=/
All subsequent actions occur on the server running the duplicate database.
$ orapwd file=/u01/app/oracle/product/11.2.0/db_1/dbs/orapwDB11G
password=password entries=10
Add the appropriate entries into the "tnsnames.ora" file in the "$ORACLE_HOME/network/admin"
directory to allow connections to the target database from the duplicate server.
Create a PFILE for the duplicate database. Since we are duplicating the database onto a separate
server with the same filesystem as the original, we don't need to convert the file names. In this case,
the PFILE is called "initDB11G.ora" and is placed in the "$ORACLE_HOME/dbs" directory.
# Minimum Requirement.
DB_NAME=DB11G
We don't need all the other parameters as the clone will copy the SPFILE from the primary database.
If you are duplicating a database on the same machine you will probably need to create a
PFFILE/SPFILE manually from the primary database SPFILE, manually change the values and avoid
the SPFILE clause in the duplicate command.
$ mkdir -p /u01/app/oracle/oradata/DB11G
$ mkdir -p /u01/app/oracle/fast_recovery_area/DB11G
$ mkdir -p /u01/app/oracle/admin/DB11G/adump
Make the backup files from the source database available to the destination server. That can be done
by either copying them to the matching location on the destination server, or placing them on a shared
drive. If you are copying the files, you may want to use the following type of commands.
$ scp -r
oracle@ol5-112-dup1:/u01/app/oracle/fast_recovery_area/DB11G/archivelog
/u01/app/oracle/fast_recovery_area/DB11G
$ scp -r
oracle@ol5-112-dup1:/u01/app/oracle/fast_recovery_area/DB11G/backupset
/u01/app/oracle/fast_recovery_area/DB11G
$ scp -r
oracle@ol5-112-dup1:/u01/app/oracle/fast_recovery_area/DB11G/autobackup
/u01/app/oracle/fast_recovery_area/DB11G
With the duplicate database started we can now connect to it from RMAN. For the duplication to work
we must connect to the duplicate database (AUXILIARY), but depending on the type of duplication we
are doing we may optionally connect to the original database (TARGET) and/or the recovery catalog
(CATALOG).
$ rman AUXILIARY /
$ rman TARGET sys/password@DB11G-SOURCE AUXILIARY /
$ rman CATALOG rman/password@rman-catalog AUXILIARY /
$ rman TARGET sys/password@DB11G-SOURCE CATALOG rman/password@rman-catalog
AUXILIARY /
We can then duplicate the database using one of the following commands. Remember, remove the
SPFILE clause if you have manually created a full PFILE or SPFILE.
The time it takes to complete varies depending on the size of the database and the specification of the
server. Once the process is finished RMAN produces a completion message and you have your
duplicate instance.
Oracle 11g introduced the ability to create duplicate databases directly without the need for a backup.
This is known as active database duplication. The process is similar to the backup-based duplication,
with a few exceptions.
First, and most obviously, you don't need a backup of the source system, but it does have to be
in ARCHIVELOG mode.
The passwords in the password files must match for both servers, so remember to set the correct
password when creating the password file on the destination server.
Both the source and destination database servers require a "tnsnames.ora" entry for the destination
database. In this case I added the following to each server. The destination server still requires the
source entry shown in the previous section.
The destination server requires static listener configuration in a "listener.ora" file. In this case I used
the following configuration. Remember to restart or reload the listener.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = DB11G.WORLD)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = DB11G)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ol5-112-dup2.localdomain)(PORT =
1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
When connecting to RMAN, you must use a connect string for both the target and auxiliary
connections.