Step1: Take rman backup.
#!/bin/ksh
key=`date +%Y.%m.%d.%H.%M`
ldir=/oracle/exports
lname=db_name_stby_rman_bkp.log
logname=$ldir/$lname.$key
echo $logname
set ORACLE_SID=DB_NAME
echo $ORACLE_HOME
echo $ORACLE_SID
$ORACLE_HOME/bin/rman target sys/"password" nocatalog << EOF
spool log to $logname
run {
allocate channel t1 type disk;
allocate channel t2 type disk;
allocate channel t3 type disk;
allocate channel t4 type disk;
backup as compressed backupset
format '/oracle/exports/db_name_DB_%U_%t'
(database);
release channel t1;
release channel t2;
release channel t3;
release channel t4;
}
run {
allocate channel t1 type disk;
allocate channel t2 type disk;
allocate channel t3 type disk;
allocate channel t4 type disk;
sql 'alter system archive log current';
backup as compressed backupset
format '/oracle/exports/db_name_arch_%t_%s.dbf'
(archivelog all);
release channel t1;
release channel t2;
release channel t3;
release channel t4;
}
run {
allocate channel t1 device type disk format '/oracle/exports/db_name_stb_control_%U';
backup current controlfile for standby ;
}
quit
EOF
Step2: Transfer backup Dr server.
FTP or SCP the backup pieces.
+ If the backups are on NFS mount then mount the NFS on standby server with the same name as you mounted on primary database.
+ Until 9i, you need to move the backup-pieces in exactly the same location on standby as they were created on primary.
+ From 10g onwards, use CATALOG BACKUPPIECE command if you are moving backup-pieces to a different location.
+ If the backups are on tape then make sure that you make proper changes on standby server so that you can restore the backups on standby server.
Step 3: Make proper changes in the parameter files of both primary and standby database
Add the below parameter in primary database parameter file :
log_archive_dest_2='SERVICE=STANDBY'
Step 4: Copy the primary database parameter file and make necessary changes :
db_unique_name='standby'
instance_name='standby'
db_file_name_convert='/u01/oracle/product/oradata/PROD/data/','/u01/oracle/product/PROD/oradata/standby/data/','/log_file_name_convert='/u01/oracle/product/oradata/PROD/log/','/u01/oracle/product/PROD/oradata/standby/log'
standby_archive_dest='/u01/oraclCopy the primary database parameter file and make necessary changes :
db_unique_name='standby'
instance_name='standby'
db_file_name_convert='/u01/oracle/product/oradata/PROD/data/','/u01/oracle/product/PROD/oradata/standby/data/','/log_file_name_convert='/u01/oracle/product/oradata/PROD/log/','/u01/oracle/product/PROD/oradata/standby/log'
standby_archive_dest='/u01/oracle/product/PROD/oradata/standby/arch1'e/product/PROD/oradata/standby/arch1'
Step 5: Restore database in dr :
key=`date +%Y.%m.%d.%H.%M`
ldir=/oracle/exports/
lname=db_name_stby_reco_rman.log
logname=$ldir/$lname.$key
echo $logname
rman target sys/'password'@db_name auxiliary / << EOF
spool log to $logname
run {
allocate auxiliary channel t1 device type disk;
allocate auxiliary channel t2 device type disk;
allocate auxiliary channel t3 device type disk;
allocate auxiliary channel t4 device type disk;
duplicate target database for standby
nofilenamecheck;
}
quit
EOF
Step6: Once restore is completed shutdown database.
shutdown immediate;
step7: start the database in mrp mode
startup nomount
alter database mount standby database;
alter database recover managed standby database disconnect from session;
No comments:
Post a Comment