Tuesday, August 28, 2012

Steps for Configuring DATAGUARD in Oracle 11g

DATAGUARD CONFIGURATION STEPS:-

Environment
Primary Database DB_UNIQUE_NAME: ORCL
Standby Database DB_UNIQUE_NAME: ORCL_DTGD
ORACLE_SID: ORCL

STEPS:-
1. Enable Force Logging on the Primary database

SQL> alter database force logging;

2. Create password file on Primary database.
3. Create listener.ora,tnsnames.ora on standby database.
LISTENER/TNS FOR PRIMARY DATABASE:-
LISTENERORCL=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=10.0.7.115)(PORT=1521))
(ADDRESS=(PROTOCOL=ipc)(KEY=extproc))))
SID_LIST_LISTENERORCL=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=ORCL)
(ORACLE_HOME=/data/oracle/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME=ORCL))
(SID_DESC=
(GLOBAL_DBNAME=ORCL_DGMGRL)
(ORACLE_HOME=/data/oracle/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME=ORCL))
(SID_DESC=
(SID_NAME=plsextproc)
(ORACLE_HOME=/data/oracle/app/oracle/product/11.2.0/dbhome_1)
(PROGRAM=extproc)))


ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.7.115)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = ORCL)
)
)

LISTENER/TNS FOR STANDBY DATABASE:-

ORCL_DTGD=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=10.0.7.116)(PORT=1521))
(ADDRESS=(PROTOCOL=ipc)(KEY=extproc))))
SID_LIST_ORCL_DTGD=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=ORCL_DTGD)
(ORACLE_HOME=/data/oracle/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME=ORCL_DTGD))
(SID_DESC=
(GLOBAL_DBNAME=ORCL_DTGD_DGMGRL)
(ORACLE_HOME=/data/oracle/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME=ORCL_DTGD))
(SID_DESC=
(SID_NAME=plsextproc)
(ORACLE_HOME=/data/oracle/app/oracle/product/11.2.0/dbhome_1)
(PROGRAM=extproc)))


ORCL_DTGD =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.7.116)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = ORCL_DTGD)
)
)

4. Create password file for standby database.
$orapwd file-orapw$ORACLE_SID password= force=y entries=10
5. Copy the password file of standby database on primary server and vice-versa.
6. Add the tns entry of primary server to standby server and vice-versa.
Now we should be albe to login on remote database using tns service name.


Note - ensure that the same password is used as the one used while creating the password file on the Primary host
7. Create a "scratch" init.ora file on the Standby host with just a single parameter

"initORCL_DTGD.ora" [New file]
DB_NAME=ORCL
DB_UNIQUE_NAME=ORCL_DTGD
Audit_file_dest=’
Background_file_dest=’


8. Create the required directories on the Standby host as mentioned in pfile.
9. Start standby database using pfile in nomount state.

On Primary database:

10. On the primary server, connect to Primary database(ORCL) as target and standby database(ORCL_DTGD) as auxiliary.
bash-3.00$ rman target sys/sys@ORCL auxiliary sys/sys@ORCL_DTGD

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Mar 30 14:26:29 2012

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

connected to target database: ORCL (DBID=1353251360)
connected to auxiliary database: ORCL (DBID=1353251360)

RMAN>DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE DORECOVER
SPFILE SET DB_UNIQUE_NAME='ORCL_DTGD' SET LOG_ARCHIVE_DEST_2='service=ORCL LGWR SYNC REGISTER VALID_FOR=(online_logfile,primary_role)' Set STANDBY_FILE_MANAGEMENT='AUTO' SET FAL_SERVER='ORCL' SET FAL_CLIENT='ORCL_DTGD' SET CONTROL_FILES='/data/oracle/app/oracle/oradata/ORCL/control01.ctl’,'/data/oracle/app/oracle/fast_recovery_area/ORCL/control02.ctl’ NOFILENAMECHECK;



11. Add init.ora parameters related to redo transport and redo apply on primary database.

SQL> alter system set fal_server='ORCL_DTGD' scope=both;
System altered.
SQL> alter system set fal_client='ORCL' scope=both;
System altered.
SQL> alter system set standby_file_management=AUTO scope=both;
System altered.
SQL> alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ORCL';
System altered.

SQL> alter system set LOG_ARCHIVE_DEST_2='SERVICE=ORCL_DTGD LGWR SYNC VALID_FOR= (ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ORCL_DTGD';

12. Shutdown the Standby database, add the Standby log files and then start real time recovery


SQL> shutdown immediate;
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.

SQL> startup
ORACLE instance started.

Total System Global Area 5344731136 bytes
Fixed Size 2153536 bytes
Variable Size 3154117568 bytes
Database Buffers 2147483648 bytes
Redo Buffers 40976384 bytes
Database mounted.
Database opened.

SQL> alter database add standby logfile group 4 size 50m;
Database altered.
SQL> alter database add standby logfile group 5 size 50m;
Database altered.
SQL> alter database add standby logfile group 6 size 50m;
Database altered.
SQL> alter database add standby logfile group 7 size 500m;
Database altered.
SQL> recover managed standby database using current logfile disconnect;
Media recovery complete.

SQL> !ps -ef |grep mrp
oracle 471268 1 0 10:51:16 - 0:02 ora_mrp0_ORCL_DTGD
oracle 475150 270568 1 11:02:47 pts/0 0:00 grep mrp


13. Change the Protection Level of the Standby Database to MAXIMIZE AVAILABILITY

On the Primary database:

SQL> shutdown immediate;

Database dismounted.
ORACLE instance shut down.

SQL> startup mount

ORACLE instance started.

Total System Global Area 5344731136 bytes
Fixed Size 2153536 bytes
Variable Size 3154117568 bytes
Database Buffers 2147483648 bytes
Redo Buffers 40976384 bytes
Database mounted.

SQL> alter database add standby logfile group 4 size 500m;

Database altered.

SQL> alter database add standby logfile group 5 size 500m;

Database altered.

SQL> alter database add standby logfile group 6 size 500m;

Database altered.

SQL> alter database add standby logfile group 7 size 500m;

Database altered.

SQL> alter database set standby database to maximize availability;

Database altered.

SQL> alter database open;

Database altered.


SQL> select protection_mode,protection_level from v$database;

PROTECTION_MODE PROTECTION_LEVEL
-------------------- --------------------
MAXIMUM AVAILABILITY MAXIMUM AVAILABILITY
14. Configuring DATAGUARD Broker.
bash-3.00$ dgmgrl
DGMGRL for Solaris: Version 11.2.0.3.0 - 64bit Production

Copyright (c) 2000, 2009, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys/sys
Connected.
DGMGRL>CREATE CONFIGURATION ‘DATAGURAD’ PRIMARY DATABASE IS ‘ORCL’ CONNECT IDENTIFIER IS ‘ORCL’;
DGMGRL>ADD DATABASE ‘ORCL_DTGD’ AS CONNECT IDENTIFIER IS ‘ORCL_DTGD’;
DGMGRL>ENABLE CONFIGURATION;
DGMGRL>SHOW CONFIGURATION;



No comments:

Post a Comment