11g RMAN Duplicate Script/Command with HP DataProtector as MML

These are the scripts to clone an Oracle 11g database using RMAN duplicate command. I use HP DataProtector (7.0) as the Media Management Layer (MML). The backup are written to tape drives. System administrator mounts the tape drives to the test servers.

Assumption:
  • You are cloning the DB to different servers. For example: Source is PROD server, Target is TEST server.
  • The file system structure is same between source and the target.
  • There is catalog database for RMAN repository. Auxiliary is the test/target database. The auxiliary instance should be up in nomount state.
  • Make sure you can do tnsping to catalog and   source/prod database.
  • HP DataProtector libraries are already installed on the target/test servers.
  • The # of channels opened are based on the network, how many tape drives are available for PROD backup and mounted on the test server by system administrator.

Usually I make rman script and save it as [SID]_clone.rman and execute it from the command line.
rman cmdfile=applet_clone.rman log=applet_clone_FEB11.log 

1. SET UNTIL TIME

Here I am trying to restore and recover the database to a certain time. I have cleaned out the target database file system before the script is executed.

Source DB: APPLE
Target/Test DB: APPLET
Oracle Version: 11.2.0.3
OS: HP UX Itanium 11.31

script:
connect auxiliary /
connect catalog APPLE/APPLE@CATLOGDB
run {
 allocate auxiliary channel 'dev_0' type 'sbt_tape' parms 'SBT_LIBRARY=/opt/omni/lib/libob2oracle8_64bit.so ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=APPLE,OB2BARLIST=APPLE_DB_3A)';
 allocate auxiliary channel 'dev_1' type 'sbt_tape' parms 'SBT_LIBRARY=/opt/omni/lib/libob2oracle8_64bit.so ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=APPLE,OB2BARLIST=APPLE_DB_3A)';
 duplicate database APPLE to APPLET
 NOFILENAMECHECK
 until time "to_date('2013-07-12 19:00:00','YYYY-MM-DD HH24:MI:SS')"
 pfile=/a01/oracle/db/11.2.0/dbs/initAPPLET.ora
 LOGFILE
   GROUP 10 (
     '/a08/appldata/log10a.dbf',
     '/a11/appldata/log10b.dbf'
   ) SIZE 400M,
   GROUP 11 (
     '/a08/appldata/log11a.dbf',
     '/a11/appldata/log11b.dbf'
   ) SIZE 400M,
   GROUP 12 (
     '/a08/appldata/log12a.dbf',
     '/a11/appldata/log12b.dbf'
   ) SIZE 300M;
   }





2. SET UNTIL SEQUENCE

Here I am trying to restore and recover the database to a certain sequence number . I have cleaned out the target database file system before the script is executed. 

How to get sequence#:
If you know the time, check the alert log of the source database

Source DB: TEX
Target/Test DB: TEXT
Oracle Version: 11.2.0.2
OS: HP UX Itanium 11.31

script:
connect auxiliary /
connect target sys/SYSPASSWORD@TEX
connect catalog TEX/TEX@CATLOGDB
run {
 SET UNTIL SEQUENCE 18394;
 allocate auxiliary channel 'dev_0' type 'sbt_tape' parms 'SBT_LIBRARY=/opt/omni/lib/libob2oracle8_64bit.so ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=TEX,OB2BARLIST=TEX)';
 allocate auxiliary channel 'dev_1' type 'sbt_tape' parms 'SBT_LIBRARY=/opt/omni/lib/libob2oracle8_64bit.so ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=TEX,OB2BARLIST=TEX)';
 allocate auxiliary channel 'dev_2' type 'sbt_tape' parms 'SBT_LIBRARY=/opt/omni/lib/libob2oracle8_64bit.so ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=TEX,OB2BARLIST=TEX)';
 duplicate database TEX to TEXT
 NOFILENAMECHECK
 pfile=/t01/oracle/texora/11.2.0/dbs/initTEXT.ora
 LOGFILE
   GROUP 1 ('/t03/texdata/redo01_a.log') SIZE 2048M,
   GROUP 2 ('/t04/texdata/redo02_a.log') SIZE 2048M,
   GROUP 3 ('/t03/texdata/redo03_a.log') SIZE 2048M,
   GROUP 4 ('/t04/texdata/redo04_a.log') SIZE 2048M,
   GROUP 5 ('/t03/texdata/redo05_a.log') SIZE 2048M;
   } 


3.  SET UNTIL SCN:

Here I am trying to restore and recover the database to a certain SCN (System Change Number) . I have cleaned out the target database file system before the script is executed. 

How to get source database SCN#:
If you know the time, run the below SQL in source DB. In this example,  the time is 19-AUG-13 01:03 AM.

SELECT LTRIM(RTRIM(TIMESTAMP_TO_SCN('19-AUG-13 01.03.00 AM'))) FROM DUAL;

or

SELECT LTRIM(RTRIM(TIMESTAMP_TO_SCN(TO_TIMESTAMP('08/19/2013 01:03:00','MM/DD/YYYY HH24:MI:SS')))) AS SCN FROM DUAL;

You can verify it by checking time with SCN value as below:

SELECT SCN_TO_TIMESTAMP(217348050501) AS TIMESTAMP FROM DUAL;

Source DB: AAM
Target/Test DB: AAMT
Oracle Version: 11.2.0.2
OS: HP UX Itanium 11.31 

script:
connect auxiliary /
connect target sys/SYSPASSWORD@AAM
connect catalog AAM/AAM@CATLOGDB
run {
 SET UNTIL SCN 209049958452;
 allocate auxiliary channel 'dev_0' type 'sbt_tape' parms 'SBT_LIBRARY=/opt/omni/lib/libob2oracle8_64bit.so ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=AAM,OB2BARLIST=AAM)';
 allocate auxiliary channel 'dev_1' type 'sbt_tape' parms 'SBT_LIBRARY=/opt/omni/lib/libob2oracle8_64bit.so ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=AAM,OB2BARLIST=AAM)';
 allocate auxiliary channel 'dev_2' type 'sbt_tape' parms 'SBT_LIBRARY=/opt/omni/lib/libob2oracle8_64bit.so ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=AAM,OB2BARLIST=AAM)';
 duplicate database AAM to AAMT
 NOFILENAMECHECK
 pfile=/m01/oracle/aamora/11.2.0/dbs/initAAMT.ora
 LOGFILE
   GROUP 1 ('/m03/aamdata/redo01_a.log') SIZE 2048M,
   GROUP 2 ('/m04/aamdata/redo02_a.log') SIZE 2048M,
   GROUP 3 ('/m03/aamdata/redo03_a.log') SIZE 2048M,
   GROUP 4 ('/m04/aamdata/redo04_a.log') SIZE 2048M,
   GROUP 5 ('/m03/aamdata/redo05_a.log') SIZE 2048M;
   }


Note: It is not mandatory to give OB2BARLIST when restore/recover is performed with HP DataProtector. It is ignored internally by the MML i.e,

allocate auxiliary channel 'dev_0' type 'sbt_tape' parms 'SBT_LIBRARY=/opt/omni/lib/libob2oracle8_64bit.so ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=AAM)';

Reference:
RMAN: Configuring HP Omniback with RMAN (Doc ID 77552.1)
RMAN and Specific Media Managers Environment Variables. (Doc ID 312737.1)

No comments:

Post a Comment