You are on page 1of 5

FIRST ESTABLISH THE CONNECTIVITY BETWEEN TWO SERVER'S ie, listener and tnsnames;

create the password file in production and copy the same password file to standb
y database dbs location;
Primary:-sqlplus / as sysdba
SQL> select force_logging from v$database;
FOR
--NO
SQL> alter database force logging;
Database altered.
SQL>
Oracle Data Guard requires the primary database to be run in FORCE LOGGING mode.
This means that statements using the NOLOGGING option will still generate redo i
nformation to maintain the Data Guard standby databases.
Primay database should be in archive log mode.
On T2COMPY:
SQL> alter system set LOG_ARCHIVE_DEST_STATE_1=ENABLE scope=BOTH;
SQL> alter system set LOG_ARCHIVE_DEST_STATE_2=ENABLE scope=BOTH;
SQL> alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(T2COMPY,T2COMPYDR)' scope=B
OTH;
SQL> alter system set LOG_ARCHIVE_DEST_1='LOCATION=/u02/archive/T2COMPY VALID_FO
R=(ALL_LOGFILES,ALL_ROLES)' scope=BOTH;
SQL> alter system set LOG_ARCHIVE_DEST_2='SERVICE=T2COMPYDR LGWR ASYNC VALID_FOR
=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=T2COMPYDR' scope=BOTH;
SQL> alter system set FAL_SERVER=T2COMPYDR scope=BOTH;
SQL> alter system set FAL_CLIENT=T2COMPY scope=BOTH;
SQL>ALTER SYSTEM SET DB_UNIQUE_NAME=T2COMPY scope=spfile;
SQL> alter system set standby_file_management='AUTO' scope=BOTH;

ALTER DATABASE ADD STANDBY LOGFILE '/u01/app/oracle/oradata/T2COMPY/standby01a.l


og' SIZE 50M ;
ALTER DATABASE ADD STANDBY LOGFILE '/u01/app/oracle/oradata/T2COMPY/standby02a.l
og' SIZE 50M ;
ALTER DATABASE ADD STANDBY LOGFILE '/u01/app/oracle/oradata/T2COMPY/standby03a.l
og' SIZE 50M ;
optional:- if the file system is different, we need to enable this parameters
********
SQL> alter system set DB_FILE_NAME_CONVERT=('/database/oradata/T2COMPYDR/','/dat
abase/oradata/T2COMPY/','/database1/oradata/T2COMPYDR/','/database1/oradata/T2CO
MPY/') scope=both;
SQL> alter system set LOG_FILE_NAME_CONVERT=('/database/oradata/T2COMPYDR/','/da
tabase/oradata/T2COMPY/','/database1/oradata/T2COMPYDR/','/database1/oradata/T2C

OMPY/') scope=both;
================================================================================
======================================================
======================
On T2COMPYDR Side:
==========================
[oracle@linux2 dbs]$ orapwd file=orapwT2COMPYDR password=sys force=y
vi initT2COMPYDR.ora
db_name=T2COMPY
:wq!
make necessary changes in the pfile
[oracle@linux2
[oracle@linux2
[oracle@linux2
[oracle@linux2
[oracle@linux2

dbs]$
dbs]$ export ORACLE_SID=T2COMPYDR
dbs]$
dbs]$
dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sun Feb 24 17:37:21 2013


Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> create spfile from pfile;
File created.
SQL> startup nomount;
On T2COMPYDR: ALTER SYSTEM REGISTER;
CREATE STANDBY ARCHIVE DIRECTORY '/archive/T2COMPY'
SQL> alter system set LOG_ARCHIVE_DEST_STATE_1=ENABLE scope=BOTH;
SQL> alter system set LOG_ARCHIVE_DEST_STATE_2=ENABLE scope=BOTH;
SQL> alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(T2COMPY,T2COMPYDR)' scope=B
OTH;
SQL> alter system set LOG_ARCHIVE_DEST_1='LOCATION=/u02/archive/T2COMPYDR VALID_
FOR=(ALL_LOGFILES,ALL_ROLES)' scope=BOTH;
SQL> alter system set LOG_ARCHIVE_DEST_2='SERVICE=T2COMPY LGWR ASYNC VALID_FOR=(
ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=T2COMPY';
SQL> alter system set FAL_SERVER=T2COMPY scope=BOTH;
SQL> alter system set FAL_CLIENT=T2COMPYDR scope=BOTH;
SQL> alter system set standby_file_management='AUTO' scope=BOTH;
SQL> alter system set db_name='T2COMPY' scope=spfile ;
SQL> alter system set db_unique_name='T2COMPYDR' scope=spfile ;
SQL> alter system set standby_archive_dest='/u02/archive/T2COMPY' scope=both
SQL> shutdown immediate
SQL> STARTUP NOMOUNT

optional:- if the file system is different we need to enable this parameters;


=========
SQL> alter system set DB_FILE_NAME_CONVERT=('/database/oradata/T2COMPY/','/datab
ase/oradata/T2COMPYDR/','/database1/oradata/T2COMPY/','/database1/oradata/T2COMP
YDR/') scope=spfile;
SQL> alter system set LOG_FILE_NAME_CONVERT=('/database/oradata/T2COMPY/','/data
base/oradata/T2COMPYDR/','/database1/oradata/T2COMPY/','/database1/oradata/T2COM
PYDR/') scope=spfile;

================================================================================
==============================================
check the listener and tnsnames connectivity with sqlplus sys/sys@T2COMPY as sys
dba , sqlplus sys/sys@T2COMPYDR as sysdba
from both sides , ie, from primay and standby side
Standby:rman target sys/passw@tns auxiliary sys/paswd@standbytns
rman>duplicate target database for standby from active database nofilenamecheck;
================================================================================
======================================================
STANDBY:
sql> shut immediate;
startup nomount
alter database mount standby database;
alter database recover managed standby database disconnect from session;
select status, process, sequence# from v$managed_standby;
We query the standby database. The logs were successfully transported and applie
d.
SQL> select sequence#, first_time, applied from v$archived_log order by sequence
#;

switch over :
primary:========
sql> alter database commit to switchover to physical standby with session shutdo
wn;
shut immediate;
standby:============
sql> alter database recover managed standby database finish force;

sql>alter database commit to switchover to physical primary;


sql>shutdown immediate
sql>startup
select name, open_mode,database_role, switchover_Status from v$database;
READ WRITE Mode
primary:
------sql>startup nomount;
alter database mount standby database;
alter database recover managed standby database disconnect from session;
select process, sequence#,status from v$managed_standby;
standby -- primary:select recovery_mode from v$archive_dest_status; ----> to check the database in
recovery mode or not;
================================================================================
=========================================================================
On DASHPRD Side:
$ rman target sys/n01h3r3@dashprd auxiliary sys/n01h3r3@dashsby
connected to target database: DASHPRD (DBID=2428063449)
connected to auxiliary database: DASHPRD (not mounted)
RMAN> run {
allocate channel prmy1 type disk;
allocate channel prmy2 type disk;
allocate channel prmy3 type disk;
allocate channel prmy4 type disk;
allocate auxiliary channel stby type disk;
duplicate target database for standby from active database ;
}
On DASHSBY Side:
sqlplus / as sysdba
SQL> shutdown immediate
SQL> startup mount ;
SQL> alter database recover managed standby database disconnect from session;
SQL> exit
On DASHPRD and DASHSBY Run the following to under RMAN so archive log do not get
removed by the backup until its applied on standby:
rman target /
run {
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;
}
On DASHSBY check SEQ_checks:
SELECT THREAD#, MAX(SEQUENCE#) FROM V$ARCHIVED_LOG WHERE APPLIED = 'YES' AND RES
ETLOGS_CHANGE# = (SELECT RESETLOGS_CHANGE#
FROM V$DATABASE_INCARNATION WHERE STATUS = 'CURRENT') GROUP BY THREAD# ;

On T2COMPY check SEQ_Check:


SQL> alter system switch logfile ;
System altered.
SQL> SELECT THREAD#, SEQUENCE# FROM V$THREAD;
THREAD# SEQUENCE#
---------- ---------1
1410
================================================================================
===========================================================================
desc v$managed_standby
desc v$archive_dest_status
desc v$archived_log
desc v$archive_gap
desc v$recover_file
desc v$redo_dest_resp_histogram

Failover:If the primary database is not available the standby database can be activated a
s a primary database using the following statements.
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;
ALTER DATABASE ACTIVATE STANDBY DATABASE;
Since the standby database is now the primary database it should be backed up im
mediately.
The original primary database can now be configured as a standby. If Flashback D
atabase was enabled on the primary database, then this can be done relatively ea
sily (shown here). If not, the whole setup process must be followed, but this ti
me using the original primary server as the standby.