Tuesday, June 7, 2011

DATA GUARD ON ORACLE10g


To implements this method you have to have two machines connected to each other you can use VMware  machine or two separate systems (if you can arrange that) after installing oracle software create database using same structure (Recommended oracle managed file system) configured TNS listener on both machines. Make sure both machines are connected to each other by doing the following, connect sys/oracle @(instance name) as sysdba it will ans as connected if not check the connection again.
Now that we have connected both machines shutdown the standby database and mount the primary database set the prim database in archive log by doing the following ALTER DATABASE ARCHIVELOG; and enable force logging by doing the following ALTER DATABASE FORCE LOGGING now it’s time to set the parameters for primary database:
Setting up prim database perameters
Alter system set DB_NAME=primary (already aveleble)
Alter system set DB_UNIQUE_NAME=primary scope=spfile
Alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(primary,standby)'
Alter system set LOG_ARCHIVE_DEST_1='LOCATION= D:\path VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=PRIMARY'

Alter system set LOG_ARCHIVE_DEST_2='SERVICE=stndVALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)DB_UNIQUE_NAME=stnd'
Alter system set LOG_ARCHIVE_DEST_STATE_1=ENABLE
Alter system set LOG_ARCHIVE_DEST_STATE_2=ENABLE

Alter system set REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE scope=spfile not necessary

Alter system set LOG_ARCHIVE_MAX_PROCESSES=30 no necessary

Alter system set FAL_SERVER=standby

Alter system set FAL_CLIENT=primary

Alter system set STANDBY_FILE_MANAGEMENT=AUTO

Alter system set SERVICE_NAMES=prim scope=spfile

Alter system set INSTANCE_NAME=prim scope=spfile;

Alter database set DG_broker=true (if you want to enable the database guard broker)

now shutdown the database and copy all datafiles+onlin logfiles batter if copied everything from primary to standby but be sure to past it in its respected place.

Mount the primary database again and create a stand by controlfile

Alter database create standby controlfile as ‘path\name.ctl’;

Configuring standby machine
The first thing you have to do after pasting all the datafile and online logs on standby database is to restore the standby controlfile
rman> startup nomount;
rman> restore standby controlfile from ‘path\name.ctl’

Now startup database in mount using sqlplus and change parameters of standby database.

Alter system set DB_NAME=primary

Alter system set DB_UNIQUE_NAME=standby scope=spfile

Alter system set SERVICE_NAMES=standby

Alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(primary,standby)'

Alter system set DB_FILE_NAME_CONVERT=’O:\oracle\product\10.2.0\oradata\primary’,’ O:\oracle\product\10.2.0\oradata\standby’ scope=spfile

Alter system set LOG_FILE_NAME_CONVERT=’O:\oracle\product\10.2.0\oradata\primary’,’ O:\oracle\product\10.2.0\oradata\standby’scope=spfile

Alter system set LOG_ARCHIVE_DEST_1='LOCATION=any-path VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=standby'

Alter system set LOG_ARCHIVE_DEST_2='SERVICE=primary VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)DB_UNIQUE_NAME=primary'

Alter system set LOG_ARCHIVE_DEST_STATE_1=ENABLE

Alter system set LOG_ARCHIVE_DEST_STATE_2=ENABLE

REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE  (not necessary)

Alter system set LOG_ARCHIVE_MAX_PROCESSES=30 (not necessary)

Alter system set STANDBY_FILE_MANAGEMENT=AUTO

Alter system set INSTANCE_NAME=standby

Alter system set FAL_SERVER=primary

Alter system set FAL_CLIENT=standby

Alter system set Lock_name_space=standby scope=spfile


Now startup standby database in nomount stage startup nomount; and issue the following cmd alter database mount standby database;

You can add standby redologs for DG_broker by doing the following
Alter database add standby logfile ’path\name.log’ size ??m;


Now that all configurations is done we have to make sure that archiveing is applied on standby by by primary
From primary issue this cmd

Alter system set Log_archive_dest_state_2=ENABLE scope=both;

Check the list of archivelogs when ever you switch a log check logs on both instance you will see both changing if not then check you alert logfile

Archive Log List;

 And also check if there any error in archiveing destination

Select Status, Error from v$Archive_dest where dest_id=2;

Now on standby issue this cmd

Alter Database Recover Managed Standby Database Disconnect;

And check that the standby database is receiving logs properly

Select name,applied,archived from v$archived_log;
 Status of archiveing can also be checked on both machines by issuing the following cmd

SELECT DEST_ID "ID",
STATUS "DB_status",
DESTINATION "Archive_dest",
ERROR "Error"
FROM V$ARCHIVE_DEST;

SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME
FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

SELECT SEQUENCE#, APPLIED FROM V$ARCHIVED_LOG
ORDER BY SEQUENCE#;..
Thank you for Reading..