ORACLE STANDBY DATABASE ( DATA GUARD)

A standby database is a transactionally consistent copy of an Oracle production database that is initially created from a backup copy of the primary database. Once the standby database is created and configured, Oracle Data Guard automatically maintains the standby database by transmitting primary database redo data to the standby system, where the redo data is applied to the standby database.
        Oracle 11g Release 2, a single Oracle Data Guard configuration can contain up to 30 standby databases in 3 standby database configurations: physical, snapshot, and logical. All three types of standby databases can be Oracle RAC or single-instance, regardless of the configuration of the primary database. The overall layout of your Oracle Data Guard configuration is dependent on what business requirements must be satisfied by the configuration.

A standby database can be of three types.


1)Physical Standby Database

2)Logical Standby Database
3)Snapshot Standby Database


1)Physical Standby Database:


          A physical standby database is an identical copy of the primary database. The disk structures are also identical with primary database. It is kept synchronized with the primary database by Redo Apply- which means the redo data is received from the primary database and then redo is applied to the physical standbydatabase.

         Note that as of Oracle Database 11g release 1 (11.1), a physical standby database can receive and apply redo while it is open for read-only access. You can use physical standbydatabase for query and reporting purpose along with data protection.

2)Logical Standby Database:


            A logical standby database is the same logical information of the primary database. The physical data structure need not to be same on the standbydatabase. It is kept synchronized with the primary database by SQL Apply- which means the redo data is received from the primary database, transforms redo data into SQL statements and at last executes the SQL statements on the standby database.

            You can use logical standby database for query and reporting purpose along with data protection. Also you have to facility to upgrade oracle database software and patch sets along with data protection with help of logical standby database.

3)Snapshot Standby Database:


          A snapshot standby database is a convertible copy of the physical standby database but the difference from the physical or logical standby database is, the redo data that it received does not apply into it. The redo is applied whenever it is converted back to the physical standby database. You can play with the snapshot standbydatabase and while converting to physical standby database from snapshot standbydatabase these local updates are discarded.





HOW TO ROLL FORWORD STANDBY DATABASE IN 11G IN CASE OF ASM STORAGE

 Refer the following step for the roll-forword operation.

ON STANDBY:

SQL> SELECT CURRENT_SCN FROM V$DATABASE;
CURRENT_SCN
--------------
3164433 

SQL> select min(fhscn) from x$kcvfh;

MIN(FHSCN)
----------------
3162298

SQL> select min(f.fhscn) from x$kcvfh f, v$datafile d
      where f.hxfil =d.file#
        and d.enabled != 'READ ONLY'     ;

MIN(F.FHSCN)
----------------
3162298;

ON PROD

RMAN> BACKUP INCREMENTAL FROM SCN 3162298 DATABASE FORMAT '/tmp/ForStandby_%U' tag 'FORSTANDBY';

RMAN> BACKUP CURRENT CONTROLFILE FOR STANDBY FORMAT '/tmp/ForStandbyCTRL.bck';

then copy

primary $ scp /tmp/ForStandby_* standby:/tmp

on STANDBY


RMAN> CATALOG START WITH '/tmp/ForStandby'; 

using target database control file instead of recovery catalog 
searching for all files that match the pattern /tmp/ForStandby 

List of Files Unknown to the Database 
===================================== 
File Name: /tmp/ForStandby_2lkglss4_1_1 
File Name: /tmp/ForStandby_2mkglst8_1_1 

Do you really want to catalog the above files (enter YES or NO)? YES 
cataloging files... 
cataloging done 

List of Cataloged Files 
======================= 
File Name: /tmp/ForStandby_2lkglss4_1_1 
File Name: /tmp/ForStandby_2mkglst8_1_1


RMAN> RECOVER DATABASE NOREDO; 

starting recover at 03-JUN-09 
allocated channel: ORA_DISK_1 
channel ORA_DISK_1: sid=28 devtype=DISK 
channel ORA_DISK_1: starting incremental datafile backupset restore 
channel ORA_DISK_1: specifying datafile(s) to restore from backup set 
destination for restore of datafile 00001: +DATA/mystd/datafile/system.297.688213333 
destination for restore of datafile 00002: +DATA/mystd/datafile/undotbs1.268.688213335 
destination for restore of datafile 00003: +DATA/mystd/datafile/sysaux.267.688213333 
channel ORA_DISK_1: reading from backup piece /tmp/ForStandby_2lkglss4_1_1 
channel ORA_DISK_1: restored backup piece 1 
piece handle=/tmp/ForStandby_2lkglss4_1_1 tag=FORSTANDBY 
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02 
Finished recover at 03-JUN-09

SQL> spool datafile_names_step8.txt
set lines 200
col name format a60
select file#, name from v$datafile order by file# ;
spool off


RMAN> SHUTDOWN IMMEDIATE ;
RMAN> STARTUP NOMOUNT; 
RMAN> RESTORE STANDBY CONTROLFILE FROM '/tmp/ForStandbyCTRL.bck'; 

Starting restore at 03-JUN-09 
using target database control file instead of recovery catalog 
allocated channel: ORA_DISK_1 
channel ORA_DISK_1: sid=36 devtype=DISK 

channel ORA_DISK_1: restoring control file 
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07 
output filename=+DATA/mystd/controlfile/current.257.688583989 
Finished restore at 03-JUN-09


SQL> SHUTDOWN; 
SQL> STARTUP MOUNT;



RMAN> CATALOG START WITH '+DATA/mystd/datafile/'; 

List of Files Unknown to the Database 
===================================== 
File Name: +data/mystd/DATAFILE/SYSTEM.309.685535773 
File Name: +data/mystd/DATAFILE/SYSAUX.301.685535773 
File Name: +data/mystd/DATAFILE/UNDOTBS1.302.685535775 
File Name: +data/mystd/DATAFILE/SYSTEM.297.688213333 
File Name: +data/mystd/DATAFILE/SYSAUX.267.688213333 
File Name: +data/mystd/DATAFILE/UNDOTBS1.268.688213335 

Do you really want to catalog the above files (enter YES or NO)? YES 
cataloging files... 
cataloging done 

List of Cataloged Files 
======================= 
File Name: +data/mystd/DATAFILE/SYSTEM.297.688213333 
File Name: +data/mystd/DATAFILE/SYSAUX.267.688213333 
File Name: +data/mystd/DATAFILE/UNDOTBS1.268.688213335


RMAN> SWITCH DATABASE TO COPY; 

datafile 1 switched to datafile copy "+DATA/mystd/datafile/system.297.688213333" 
datafile 2 switched to datafile copy "+DATA/mystd/datafile/undotbs1.268.688213335" 
datafile 3 switched to datafile copy "+DATA/mystd/datafile/sysaux.267.688213333"


SQL> ALTER DATABASE CLEAR LOGFILE GROUP [group number];

AND THE START THE APPLY PROCESS ON STANDBY DATABASE.


Comments

Popular posts from this blog

ORACLE GOLDENGATE

ORACLE RAC QUESTION

EXADATA ARCHITECTURE IN ORACLE