Author: Burleson
With every release of Oracle we see many configuration and manageability enhancements. Many issues have been rectified and many facilities are provided to make the life of database administrator easier.
RMAN utility can be used to copy the database structures and metadata when you instantiate an entire database for Oracle Streams. The database cloning method is employed when you use RMAN. The RMAN DUPLICATE command is used to create a valid destination database. In this article I will discuss the steps involved in this process.
Create Backup with RMAN:
First of all you will create a backup with RMAN. Using the valid backup enables you to set up a destination database without interrupting the source database operations.
Create Database Link:
Now create a database link on the source database pointing to the destination database. The propagation process will use the database link.
Define Propagation:
Define propagation to the destination queue. You can use the add_global_propagation_rule procedure of dbms_streams_adm to create the propagation. This propagation will be created at the destination database. It will be kept disabled as the destination is not yet ready.
Capture Process:
Configure and start a capture process at the source database. add_global_rule procedure of dbms_streams_adm can be used for this purpose. This will allow you to capture all supported changes in the database. However this will not include the SYS and SYSTEM schemas.
Instantiation:
Now prepare the database for instantiation by executing the dbms_capture_adm.prepare_global_instantiation procedure. The effect of this procedure execution is to put the data dictionary information for all objects in the database into the redo logs, enabling the information to be propagated to all destination sites. This procedure also sets the instantiation SCN at the source database, so it can be read by the export utility.
EXEC DBMS_CAPTURE_ADM.PREPARE_GLOBAL_INSTANTIATION();
Current SCN:
Use the dbms_flashback package to get the current SCN. This value will be used during instantiation at the destination site, as well as by RMAN when duplicating the database.
SET SERVEROUTPUT ON
DECLARE
until_scn NUMBER;
BEGIN
until_scn:=
DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER;
DBMS_OUTPUT.PUT_LINE(‘Until SCN: ‘ || until_scn);
END;
Archiving:
Now archive the current redo log by using below statement
ALTER SYSTEM ARCHIVE REDO LOG CURRENT;
RMAN:
Now start RMAN and issue the duplicate command. When you execute the duplicate command, RMAN performs an incomplete recovery, using all available incremental backups and archived logs. You also need to do a log switch on the source site, so the log containing the instantiation SCN can be archived. Once this log file is archived, make it available for RMAN to use when performing the duplicate command. Then, use the RMAN command as shown:
RUN {
SET UNTIL SCN xxxxxxx
DUPLICATE TARGET DATABASE TO DBSITE2.world
NOFILENAME CHECK OPEN RESTRICTED;}
Before running the RMAN DUPLICATE command, you must configure your system to support the database duplication. When you use the UNTIL SCN clause, RMAN recovers the database up to, but not including the specified SCN value. So, specify a value of until_scn + 1 for the ‘xxxxxxx’ shown in the example.
Destination Database:
Now connect to the destination database. Once RMAN creates the destination database then change the global name of this database to be different from the name of the source database.
ALTER DATABASE RENAME GLOBAL_NAME TO DBNEW.world;
Streams Configuration:
Now execute the remove_streams_configuration procedure in the dbms_streams_adm package at the destination site. This is needed because the duplicate database at the destination site has the entire old streams configuration. You can drop the details by executing below command. You must enable restricted session in order to run this command.
EXEC DBMS_STREAMS_ADM.REMOVE_STREAMS_CONFIGURATION();
Disable Restricted Session:
At the end you need to disable the restricted session.
ALTER SYSTEM DISABLE RESTRICTED SESSION;