Wednesday, June 20, 2012

Oracle Database Replication (From RMAN Backup)

1. Take a Full RMAN backup at Source system and do FTP from source to Test
2. @TEST: set oracle SID as the same name as Source Database
3. $ rman target / nocatalog
4. RMAN> set dbid  1234567890 (DBID of Source database)

5. start Oracle Instance as below (pfile parameters need to be adjusted according to Memory size )
RMAN> startup nomount pfile='/app/u01/oracle/product/10.2.0/db_1/dbs/initorcl.ora'
6. Restore control file from backup location, assuming control file was backed up with RMAN Full backup
RMAN> restore controlfile from '/app/u03/rman_backup/rman_level0_weekly_130112/controlfile_dbn0l8ll_1_1';


7. Mount the database after restoring control file:
RMAN> alter database mount

8. Catalog the Backup location:
RMAN> catalog start with '/app/u03/rman_backup/rman_level0_weekly_130112';

9. list incarnation of database;
    reset database to incarnation 1;
   [the parent id]


10. Exit from RMAN, go to RMAN_Restore script location and run Restore_RMAN.sh in background:
    nohup ./Restore_RMAN.sh &

------- RMAN restore Script -------------------------------------------------------------------------
#!/bin/bash
ORACLE_BASE=/app/u01/oracle; export ORACLE_BASE;
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1; export ORACLE_HOME;
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH;
#LD_LIBRARY_PATH_64=$ORACLE_HOME/lib; export LD_LIBRARY_PATH_64;
PATH=$PATH:$ORACLE_HOME/bin
export PATH

ORACLE_SID=orcl; export ORACLE_SID

TODAY=`date '+%Y%m%d_%H%M%S'`

LOG_FILE=/home/oracle/DBA_Scripts/RMAN/${ORACLE_SID}_full_restore.log
echo "ORCL full restore started at `date`" >$LOG_FILE
rman <<! >>$LOG_FILE
connect target /
run {
allocate channel ch1 device type disk;
allocate channel ch2 device type disk;
allocate channel ch3 device type disk;
allocate channel ch4 device type disk;
restore database;
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
}

!

echo "ORCL full restore finished at `date`" >>$LOG_FILE


---------------------------------------------------------------------------------------------------

11.  After completion of Restore, find the highest SCN number and Recover Database accordingly with that SCN number:

    SQL> select group#, to_char(first_change#), status, archived from v$log order by FIRST_CHANGE# desc;
    RMAN> recover database until scn 9900929507575;
    RMAN> alter database open resetlogs;











No comments:

Post a Comment