Friday 28 October 2011

Oracle Database Dataguard 11g R2 configuration on Linux

Oracle Dataguard 11g R2_x64 configuration on OEL5_x64.

Overview:
This article is a comprehensive guide for the configuration of Oracle Dataguard with Database 11g Release 2 (11.2.0.1.0) x64 on the Oracle Enterprise Linux 5 (OEL5) x64 Operating System Environment.
Please do keep in mind that this article should not be considered a substitution of the official guide from Oracle (http://www.oracle.com). The below mentioned link can be used to download the official dataguard configuration guide for Oracle Database 11g.



Objective of the Article:
By the time we finish this article, we should be able to understand the following:
(1)Installation of oracle database (11.2.0.1.0) x64 on Oracle Enterprise Linux 5 (OEL5) x64.
(3)Creation & configuration of general-purpose Oracle11g (11.2.0.1.0) database that makes use of the local file system for physical database file storage (control files, data files, flash recovery area, online redo log files).
(4)Configuration of Dataguard ( Physical Standby ) with oracle database (11.2.0.1.0) x64 on Oracle Enterprise Linux 5 (OEL5) x64.




Installation of OEL5 x64:
Install Oracle Enterprise Linux 5 x64 on your machine.
For More information about OEL5 installation visit the below site::



Parameters Used in the Article:
 Node1(Primary)  Node2(Standby)
 Machine Name  DG1  DG2
 IP Address  192.168.15.100  192.168.15.101
 Oracle Database Version  11g Ent. R2(11.2.0.1)- 64bit  11g Ent. R2(11.2.0.1)- 64bit
 DB Service Name  orcl  stdby
 Oracle Software Owner  O/S User – oracle  O/S User – oracle
Do the below mentioned activity on both the nodes ( dg1 , dg2 ).
Open the "/etc/hosts" file and add the entries similar to the following:
192.168.15.100 DG1
192.168.15.101 DG2
[root@dg1 ~]# vim /etc/hosts
[root@dg2 ~]# vim /etc/hosts




Prerequisites check & Database Installation:
For completing the prerequisites and installation of Oracle Database 11g R2 x64 on OEL5 x64, please visit the below mentioned link:
Link for database 11gR2 installtion on Oralce Enterprise Linux x64
Follow the instructions given in the above link and follow the steps till "Listener Creation" on both the machines ( DG1 and DG2 ) including "Listener Creation".


Database Creation:
For creation of Database, please visit the below mentioned link:
Link for database creation
Create database on node1 (DG1) only. For the purpose of this article, we will use "orcl" as databae name.
Global Database Name - orcl



Setting User Environment:
Setting the environment for "oracle" user. For setting so, do the following( Do the below activity on both the nodes(dg1,dg2)):
[root@dg1 ~]# su - oracle
[oracle@dg1 ~]$ vim ~/.bash_profile
Add the lines, similar to below and save the file ( According to your path, please use the values).
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin

 For screenshots ::: www.sensehaze.com

Listener Entries:
Edit the file "tnsnames.ora" on both the nodes and add the entries for both the nodes (dg1,dg2) database (orcl , stdby).
Enable "force logging" and "archive logging":
Do the below activities only on the first node ( DG1 ).
To check whether the database is in "archivelog mode", connect to the database and fire the command:
SQL> archive log list ;
If the output shows "Database Log mode - No Archive Mode", then we have to enable archive logging.
For enabling archive logging, first we have to open the database in mount state.



If suppose we had shutdown the database, then start the database in mount mode, for doing so type the below commands:
SQL> startup mount
SQL> ALTER SYSTEM SET log_archive_format = 'orcl_%s_%t_%r.arc' SCOPE=SPFILE;
SQL> ALTER SYSTEM SET db_unique_name = 'orcl' SCOPE=SPFILE;
SQL> ALTER DATABASE FORCE LOGGING;
SQL> ALTER DATABASE ARCHIVELOG;
SQL> ALTER DATABASE OPEN;

  For screenshots ::: www.sensehaze.com

Setup Standby Redo Log Groups:
Create standby redo logfile groups ( The number of standby redo logfile groups should be atleast one more than the number of online redo logfile groups ).
This is to be done only at the primary site (DG1).
Here, we have 3 online redo logfile groups, so we will create 4 standby redo logfile groups. For creating standby redo logfiles, fire the below mentioned commands:
SQL> ALTER DATABASE ADD STANDBY LOGFILE '/u01/app/oracle/oradata/orcl/srl01.log' SIZE 50M REUSE;
SQL> ALTER DATABASE ADD STANDBY LOGFILE '/u01/app/oracle/oradata/orcl/srl02.log' SIZE 50M REUSE;
SQL> ALTER DATABASE ADD STANDBY LOGFILE '/u01/app/oracle/oradata/orcl/srl03.log' SIZE 50M REUSE;
SQL> ALTER DATABASE ADD STANDBY LOGFILE '/u01/app/oracle/oradata/orcl/srl04.log' SIZE 50M REUSE;
N.B: Size of standby redofiles should be atleast equal to the size of the online redo logfiles.






Modify Primary Initialization Parameters:
The below mentioned steps to be performed on the Primary Site (DG1).
We have to set the below mentioned parameters for configuring dataguard:
—log_archive_dest_1
—log_archive_dest_state_1
—log_archive_dest_2
—log_archive_dest_state_2
—standby_file_management
—log_archive_config
—fal_server
—fal_client
For setting these parameters, fire the below mentioned commands:
SQL> ALTER SYSTEM SET log_archive_dest_1 = 'LOCATION=/u01/app/oracle/flash_recovery_area/ORCL/ DB_UNIQUE_NAME=orcl VALID_FOR=(ALL_LOGFILES,ALL_ROLES)';
SQL> ALTER SYSTEM SET log_archive_dest_state_1 = 'ENABLE';
SQL> ALTER SYSTEM SET log_archive_dest_2 = 'SERVICE=stdby DB_UNIQUE_NAME=stdby VALID_FOR=(ONLINE_LOGFILE,PRIMARY_ROLE)';
SQL> ALTER SYSTEM SET log_archive_dest_state_2 = 'ENABLE';
SQL> ALTER SYSTEM SET standby_file_management = 'AUTO';
SQL> ALTER SYSTEM SET log_archive_config = 'DG_CONFIG=(orcl,stdby)';
SQL> ALTER SYSTEM SET fal_client = 'orcl' ;
SQL> ALTER SYSTEM SET fal_server = 'stdby' ;


  For screenshots ::: www.sensehaze.com


Preparing the Standby Site:
Do these activities on second node ( DG2 ).
Create Required Directories:
(1) Create "oradata" directory and its sub-directory "oradata/stdby".
(2) Create "flash_recovery_area" directory and its sub-directory "flash_recovery_area/STDBY".
(3) Create audit files directory ( adump,dpdump etc diretories ).

Set Up Password File:
Create a Password File for the standby database. For creating password file , please run the following command:
[oracle@dg2 ~]$ orapwd file='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwstdby'
When prompted for password of SYS, Enter password for SYS.




Create Standby Initialization Parameter File:
For creating Initialization parameter file , please use any of the editors. As shown in the above screenshot:
[oracle@dg2 ~]$ vim initsby.ora
Add the line "DB_NAME=stdby" and save the file.




Start the Standby Database in nomount mode:
Now start the standby database by using this newly created pfile in nomount stage.
For doing so, please follow the steps mentioned below:
[oracle@dg2 ~]$ export ORACLE_SID=orcl
[oracle@dg2 ~]$ sqlplus sys/sys@stdby as sysdba
SQL> startup nomount pfile='/home/oracle/initsby.ora'


  For screenshots ::: www.sensehaze.com


Cloning the Standby Database:
Do this from the Primary Site ( DG1 ).
For cloning the standby database Via DUPLICATE DATABASE command, connect to the primary and auxiliary database via RMAN. As mentioned below:
[oracle@dg1 ~]$ rman target sys/sys@orcl auxiliary sys/sys@stdby




In the rman prompt type the following::
DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE
DORECOVER SPFILE
SET db_unique_name='stdby'
SET control_files='/u01/app/oracle/oradata/stdby/control01.ctl'
SET log_file_name_convert='/u01/app/oracle/oradata/orcl/','/u01/app/oracle/oradata/stdby/'
SET db_file_name_convert='/u01/app/oracle/oradata/orcl/','/u01/app/oracle/oradata/stdby/'
SET log_archive_dest_1='location=/u01/app/oracle/flash_recovery_area/STDBY/ valid_for=(ALL_LOGFILES,ALL_ROLES) db_unique_name=stdby'
SET log_archive_dest_2='service=orcl ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=orcl'
SET fal_client='stdby'
SET fal_server='orcl'
SET standby_file_management='AUTO'
SET log_archive_config='dg_config=(orcl,stdby)'
NOFILENAMECHECK;





Put Standby Database on Recovery Mode:
To put the standby database on recovery mode. Do the following:
SQL> alter database recover managed standby database disconnect;




  For screenshots of the steps, please visit the link::: www.sensehaze.com















1 comment: