You are on page 1of 5

Step By Step DATAGUARD - Within 2 hours U CAN Become a Dataguard Implementer

PRIMARY- primdb STANDBY -standdb

Ensure that the primary database is in:


1) FORCE LOGGING must be enabled
SQL> select force_logging from v$database;

2)ARCHIVELOG mode, that automatic


archiving is enabled.
SQL> archive log list

3) MAXLOGFILES >= (2 * Current Redo Log Groups) + 1:


SQL> select records_used "Current Groups",
records_total "Max Groups"
from v$controlfile_record_section
where type = 'REDO LOG';

4) Configure spfile file if not already configured

ALTER DATABASE FORCE LOGGING;


Create a directory structures in standby server.
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE

Create a Control File for the Standby Database

ALTER DATABASE CREATE STANDBY CONTROLFILE AS Copy and paste in respect control file directories in standby database server.
‘/yourdir/control1.ctl’;

Take a cold backup of all datafiles,logfiles Corresponding datafile directory.


and put into
Orapwd file=$ORACLE_HOME/dbs/pwdstanddb.ora
Create password file Password=mypass entries=5
Orapwd file=$ORACLE_HOME/dbs/pwdprimdb.ora
Password=mypass entries=5 Password must be same for both primary & standby

Prepare the Initialization Parameter


Copy and paste in respect pfile directories in standby database server
CREATE PFILE=’/yourdir/initstanddb.ora’ FROM SPFILE;
Parameters need to change:

######## Instance ############

db_name=primdb db_name=primdb

instance_name= primdb instance_name=standdb

control_files=’/.../standby/control_01.ctl’
remote_login_passwordfile=exclusive

######## File Management ############

db_file_name_convert=(’.../oradata/primdb/data1/’,’.../oradata/standdb/data1/’,
log_archive_dest_1=(’LOCATION=/disk1/oracle
’.../oradata/primdb/data2/’,’.../oradata/standdb/data2/’)
/oradata/primdb/arch’)
log_file_name_convert==(’.../oradata/primdb/logsa/’,’.../oradata/standdb/logsa/’,
log_archive_dest_2=(‘SERVICE=standdb lgwr sync’)
’.../oradata/primdb/logsb/’,’.../oradata/standdb/logsb/’)
FAL_SERVER=standdb standby_file_management=AUTO
FAL_CLIENT=primdb
remote_login_passwordfile=exclusive
Step By Step DATAGUARD - Within 2 hours U CAN Become a Dataguard Implementer

######## Archive Management ############

log_archive_start=TRUE

standby_archive_dest=’/disk1/oracle/oradata/standdb/arch’
# The following parameter is required only if the primary and standby
log_archive_format=log%d_%t_%s.arc
databases
log_archive_dest_1=(’LOCATION=/disk1/oracle/oradata/standdb/arch’)
#are located on the same system.
lock_name_space=primdbe log_archive_dest_2=(‘SERVICE=primdb lgwr sync’) #For manuall switchover

remote_archive_enable=TRUE

initprimdb.ora
Example implemented pfile: #Standby parameters
FAL_SERVER=primdb
FAL_CLIENT=standdb

#Note:

#All location related parameters , need to be changed respect to the directories created

standby database (i.e udump,bdump…)

# The following parameter is required only if the primary and standby databases

#are located on the same system.

lock_name_space=standdb

initstanddb.ora
Example implemented pfile:

Create Oracle Net Service Names for standby database Create Oracle Net Service Names for primary database
(Having both Primary & Standby database tns entries is standard (Having both Primary & Standby database tns entries is standard practice)
practice)

configure a listener for the respective databases and restart the listener configure a listener for the respective databases and restart the listener

Enable dead connection detection:

SQLNET.EXPIRE_TIME=2

Start the Physical Standby Database

STARTUP NOMOUNT pfile=’/.../standby/pfile/initstanddb.ora’;

ALTER DATABASE MOUNT STANDBY DATABASE;

Configure spfile file .


Step By Step DATAGUARD - Within 2 hours U CAN Become a Dataguard Implementer
Initiate Logshipping to the Physical Standby Database

ALTER SYSTEM SWITCH LOGFILE;

Verifying Standby Archive destination log shipping: Initiate Log Apply Services

Select status,error from v$archive_dest where dest_id=2; ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT 


SESSION;

This query includes the DISCONNECT FROM SESSION option so that log apply
services run in a background session.

Verifying the Physical Standby Database

Identify the existing archived redo logs.


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

Verify that the new archived redo log was applied.


SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY 
SEQUENCE#;

SELECT SEQUENCE#,STATUS FROM V$MANAGED_STANDBY;

SWITCH OVER

Preparing for a Switchover

Ensure LOG_ARCHIVE_DEST_2 parameter to point back to the primary database:

Sho parameter log_archive_dest_2

log_archive_dest_2=(‘SERVICE=primdb lgwr sync’)

Add Standby Redo Log Groups to Standby Database

alter database recover managed standby database cancel;

alter database open read only;

select max(group#) maxgroup from v$logfile;


#IF max groups is 3 means create a standby group as 4,5,6
select max(bytes) / 1024 "size (K)" from v$log;
#Set same size for standby logfiles.

alter database add standby logfile group 4 (…\REDO04.log') size 100m;


alter database add standby logfile group 5 (…\REDO04.log') size 100m;
alter database add standby logfile group 6 (…\REDO04.log') size 100m;

select vs.group#,vs.bytes,vl.member from v$standby_log vs,v$logfile vl where vs.grou


vl.group# order by vs.group#,vl.member;
Step By Step DATAGUARD - Within 2 hours U CAN Become a Dataguard Implementer

Add Tempfile To Standby

alter tablespace temp add tempfile '…/temp_PROD_01.dbf' size 400m reuse;

Switch back to Recovery Mode:

alter database recover managed standby database disconnect from session;

Add Standby Redo Log Groups to Primary Database

Follow the same steps mentioned in the above


“Add Standby Redo Log Groups to Standby Database”

Switch To Maximum Availability Protection Mode

Ensure log_archive_dest_2 must show LGWR SYNC

shutdown normal
startup mount
alter database set standby database to maximize availability;
alter database open;
select protection_mode from v$database;

Test Updates Propagating to Standby (wait a few seconds first):

Update some tables; Go to Open Mode:


commit; alter database recover managed standby database cancel;
alter system switch logfile; alter database open read only;
select * from (particular table which was updated in primary);
Go back to Recovery Mode:
alter database recover managed standby database disconnect from session;
Step By Step DATAGUARD - Within 2 hours U CAN Become a Dataguard Implementer
Ready To Switch Over

Ensure all activities on the primary and standby database are ended

select database_role,switchover_status from v$database;


#It should return Database_role=PRIMARY &
switchover_status = SESSIONS ACTIVE
alter database commit to switchover to physical standby with session
shutdown;

shutdown immediate;
startup nomount;
alter database mount standby database;

alter database recover managed standby database cancel;

alter database commit to switchover to primary with session shutdown;

shutdown normal;

startup;

alter database recover managed standby database disconnect from


session;

Alter database switch logfile;

Ensure archive log shipping for log_archive_dest_2 is going fine;

Select status,error from v$archive_dest where dest_id=2;

Change tnsnames.ora entry on all servers to swap the connect strings


( primdb as standdb & standdb as primdb)

To change the role again as Primary follow the same steps as To change the role again as standby follow the same steps as mentioned above
mentioned above

primedb_roughwork_ standdb_roughwork_
implementation.txt implementation.txt

Don’t learn Oracle ! Live with Oracle !

With Cheers
Palaniyappan.T
Senior Oracle Database Administrator
Hewlett Packard Globalsoft Pvt. Ltd.,
palani.ora@gmail.com

You might also like