12 June 2013
Example script: RMAN Refresh using Duplicate with Tivoli TDP
Rman Duplicate command is quite handy replacement for the old restore/recover/recreate controlfile process. This is the example of the setup and basic RMAN commands to run toduplicate database called PROD to a database called TST. All commands should be run on the test server.
Preparation:
- Set tnsnames.ora so you can connect to your production database
- Set TDP environment so TSM thinks test server is actually the production server. This is a standard trick with backup software and refreshes. Check the setup with:
- tdpoconf showenvironment -TDPO_OPTFILE=/opt/tivoli/tsm/etc/PRODSRVR/tdpo_PRODDB.opt
- Note that misleading error "SBT Initialize failed for libobk.a"on 11gR2 environment can be fixed by defining /usr/bin/dsm.opt and /usr/bin/dsm.sys files correctly, and giving the oracle user r-x privileges.
- Scp the production Block Change Tracking file to the same location
- If you don't, duplicate command fails just after the restore. You will have to manually restore archive logs, backup controlfile to trace and set the new name, as per the old process.
- Set parameters in the init.ora
- *.DB_FILE_NAME_CONVERT=(/oradata1/PROD/','/oradata2/TST/', ... etc)
- *.LOG_FILE_NAME_CONVERT=('/oradata1/PROD/','/oradata2/TST/', ... etc)
#!/bin/sh
....
/* Removed variables and error checking */
emctl start blackout TST_REFRESH TST
Shutdown
Start nomount with pfile (or prepare CONVERT parameters in advance)
....
rman nocatalog AUXILIARY / target u/p@$PRODB << EOM >> ${PROCLOG}
SET parallelmediarestore OFF;
RUN
{
SET UNTIL TIME "TO_DATE ('$RESTOREDT', '$DTFORMAT')";
allocate AUXILIARY channel t1 type 'sbt_tape' parms='ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/etc/PRODSRVR/tdpo_PRODDB.opt,
DSMI_CONFIG=/opt/tivoli/tsm/etc/PRODSRVR/dsm.opt, XINT_PROFILE=/oracle/11.2.0.3/dbs/initPRODDB.utl, PROLE_PORT=57323)';
... allocate more channels if needed...
DUPLICATE DATABASE PRODDB DBID 2442234667 TO TST;
release channel t1;
}
quit
EOM
...
Convert to noarchivelog
Remote block change tracking if not planning to do incrementals
If needed, purge recycle bin and AUD$
emctl start blackout TST_REFRESH TST