Duplicate a Database Using RMAN
A nice feature of RMAN is the ability to duplicate, or clone, a database from a previous backup. 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. In this article I'll demonstrate the last method, how to duplicate a database on the local server with a different file structure. This can prove useful when you want to recover selected objects from a backup, rather than roll back a whole database or tablespace.
Create a password file for the duplicate instance.
orapwd file=/u01/app/oracle/product/220.127.116.11.0/dbs/orapwDUP password=password entries=10
Add the appropriate entries into the "tnsnames.ora" and "listener.ora" files in the "$ORACLE_HOME/network/admin" directory. Remember to load the new configuration into the listener.
# Added to the listener.ora SID_LIST (SID_DESC = (ORACLE_HOME = /u01/app/oracle/product/18.104.22.168.0) (SID_NAME = DUP) ) # Added to the tnsnames.ora DUP = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = server1.tshcomputing.com)(PORT = 1521)) ) (CONNECT_DATA = (ORACLE_SID = DUP) ) ) # Reload listener lsnrctl reload
Create an "init.ora" file for the duplicate database. Since we are duplicating the database onto the same server as the original we must convert the file names so there is no conflict.
# Minimum Requirement. DB_NAME=DUP CONTROL_FILES=(/u02/oradata/DUP/control01.ctl, /u02/oradata/DUP/control02.ctl, /u02/oradata/DUP/control03.ctl) # Convert file names to allow for different directory structure. DB_FILE_NAME_CONVERT=(/u02/oradata/TSH1/,/u02/oradata/DUP/) LOG_FILE_NAME_CONVERT=(/u01/oradata/TSH1/,/u01/oradata/DUP/) # make sure block_size and compatible parameters # match if you are not using the default. DB_BLOCK_SIZE=8192 COMPATIBLE=22.214.171.124.0
Connect to the duplicate instance.
ORACLE_SID=DUP; export ORACLE_SID sqlplus /nolog conn / as sysdba
Create an SPFILE based on the "init.ora" file.
CREATE SPFILE FROM PFILE='/u01/app/oracle/admin/DUP/pfile/init.ora';
Start the database in
STARTUP FORCE NOMOUNT;
With the duplicate database started we can now connect to it from RMAN. For the duplication to work we must connect to the original database (TARGET), the recovery catalog (CATALOG) and our duplicate database (AUXILIARY).
ORACLE_SID=DUP; export ORACLE_SID rman TARGET sys/password@tsh1 CATALOG rman/rman@tshadm AUXILIARY /
We can then dupicate the database using one of the following commands.
# Duplicate database to TARGET's current state. DUPLICATE TARGET DATABASE TO DUP; # Duplicate database to TARGET's state 4 days ago. DUPLICATE TARGET DATABASE TO DUP UNTIL TIME 'SYSDATE-4';
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.
Note: At this point the new instance has little in the way of initialization parameters. You may want to assign figures more realistic than the defaults in the initial init.ora file.
For more information see:
Hope this helps. Regards Tim...