Saturday 10 December 2011

Oracle 10g R2 Dataguard on 32 bit RedHat Enterprise Linux 5

In this article we are going to learn, how to configure Oracle 10g R2 Dataguard on 32 bit RedHat Enterprise Linux 5.

Overview:
This article is a comprehensive guide for the configuration of Oracle Dataguard with Database 10g Release 2 (10.2.0.1.0) x86 on the RedHat Enterprise Linux 5 (RHEL5) x86 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 10g.



Objective of the Article:
By the time we finish this article, we should be able to understand the following:
(1)Installation of oracle database (10.2.0.1.0) x86 on RedHat Enterprise Linux 5 (RHEL5) x86.
(3)Creation & configuration of general-purpose Oracle 10g (10.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 (10.2.0.1.0) x86 on RedHat Enterprise Linux 5 (RHEL5) x86 by using RMAN.




Parameters Used in the Article:
   Node1(Primary)  Node2(Standby)
 Machine Name  REDHAT1  REDHAT2
 IP Address  192.168.15.100  192.168.15.101
 Oracle Database Version  10g Ent. R2(10.2.0.1)- 32 bit  10g Ent. R2(10.2.0.1)- 32 bit
 DB Service Name  mydb  mydbstb
 Oracle Software Owner  O/S User – oracle  O/S User – oracle
Do the below mentioned activity on both the nodes ( redhat1 , redhat2 ).
Open the "/etc/hosts" file and add the entries similar to the following on both the nodes:
192.168.15.100 redhat11
192.168.15.101 redhat2


Check the Ping Status of the Machines, from both the machines.
Prerequisites check & Database Installation:
For completing the prerequisites and installation of Oracle Database 10g R2 x86 on RHEL5 x86, please visit the below mentioned link:
Link for database 10g R2 installtion on RedHat Enterprise Linux x86
Follow the instructions given in the above link and follow the steps till "Listener Creation" on both the machines ( redhat1 and redhat2 ) including "Listener Creation".


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



Setting User Environment:
Setting the environment for "oracle" user. For setting so, do the following( Do the below activity on both the nodes(redhat1,redhat2)):
[root@redhat1 ~]# su - oracle
[oracle@redhat1 ~]$ 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/10.2.0/db_1
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin




After editing the profile run it for checking errors.
[oracle@redhat1 ~]$ . ~/.bash_profile
If there is any syntax error in the profile it will be reported.If there is no error then we will get the prompt silently.
This completes setting up of Oracle User Environment.
Similarly repeat the above for node2 (redhat2) also.


Listener Entries:
Edit the file "tnsnames.ora" on both the nodes and add the entries for both the nodes (redhat1,redhat2) database (mydb , mydbstb).

Similarly edit the file "Listener.ora" on both the nodes (redhat1,redhat2) and add the entries for databases.
In "redhat1" make entry for "mydb"
In "redhat2" make entry for "mydbstb"
Check "tnsping" response from both the nodes (redhat1,redhat2):
From the first node ( redhat1 ) perform the following:
[oracle@redhat1 ~]$ tnsping mydb
[oracle@redhat1 ~]$ tnsping mydbstb


Configure the Primary Database:
Do the below activities only on the first node ( redhat1 ):
Enable Archivelogging Mode:
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, 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 DATABASE ARCHIVELOG;
SQL> ALTER DATABASE OPEN;


Enable Force Logging:
SQL> alter database force logging ;

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 (redhat1).
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 GROUP 10 '/u01/app/oracle/oradata/mydb/srl01.log' SIZE 50M REUSE;
SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 11 '/u01/app/oracle/oradata/mydb/srl02.log' SIZE 50M REUSE;
SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 12 '/u01/app/oracle/oradata/mydb/srl03.log' SIZE 50M REUSE;
SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 13 '/u01/app/oracle/oradata/mydb/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 (redhat1).
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/MYDB/ DB_UNIQUE_NAME=mydb 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=mydbstb DB_UNIQUE_NAME=mydbstb VALID_FOR=(ONLINE_LOGFILE,PRIMARY_ROLE)' ;
SQL> ALTER SYSTEM SET log_archive_dest_state_2 = 'DEFER';
SQL> ALTER SYSTEM SET standby_file_management = 'AUTO' ;
SQL> ALTER SYSTEM SET log_archive_config = 'DG_CONFIG=(mydb,mydbstb)';
SQL> ALTER SYSTEM SET fal_client = 'mydb' ;
SQL> ALTER SYSTEM SET fal_server = 'mydbstb' ;


Note: We have initially put "log_archive_dest_state_2" to "DEFER" until the standby database has been created, mounted, and placed in managed recovery mode.


Create a Backup of the Primary Database:
Connect to RMAN Prompt and fire the below mentioned commands for taking backup of database.
RMAN> backup device type disk format '/u01/rman_bck/mydb_bck_%S_%U.dmp' database plus archivelog ;

Similarly backup the current controlfile for standby database.
RMAN> backup device type disk format '/u01/rman_bck/ctrl_file_bck_%U.dmp' current controlfile for standby ;

 
create an Initialization Parameter for Standby Database:
Create an initialiazation parameter file of the primary database.
SQL> create pfile='init_pfile_dest\pfile_for_stb.ora' from spfile ;


Transfer the required files to the standby Node:
Transfer "rman backups" taken and the "initialiaztion parameter file" created to the standby node.
Note: The directory structure of rman backup on both the nodes (node1 and node2) is same.

 Preparing the Standby Site:
Do these activities on second node ( redhat2 ).
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@redhat2 ~]$ orapwd file='/u01/app/oracle/product/10.2.0/db_1/dbs/orapwmydbstb' password=sys



Create Standby Initialization Parameter File:
For creating Initialization parameter file( Or we can edit the pfile of primary database and edit it for standby database) , please use any of the editors.
[oracle@dg2 ~]$ vim initsby.ora
Add the lines similar to the following:
db_name='mydbstb'
db_unique_name='mydbstb'

compatible='10.2.0.1.0'

audit_file_dest='/u01/app/oracle/admin/mydbstb/adump'
background_dump_dest='/u01/app/oracle/admin/mydbstb/bdump'
user_dump_dest='/u01/app/oracle/admin/mydbstb/udump'
core_dump_dest='/u01/app/oracle/admin/mydbstb/cdump'

control_files='/u01/app/oracle/oradata/mydbstb/control01.ctl' , '/u01/app/oracle/oradata/mydbstb/control02.ctl' , '/u01/app/oracle/oradata/mydbstb/control03.ctl'

log_archive_config='dg_config=(mydb,mydbstb)'
log_archive_dest_1 = 'LOCATION=/u01/app/oracle/flash_recovery_area/MYDB/ DB_UNIQUE_NAME=mydbstb VALID_FOR=(ALL_LOGFILES,ALL_ROLES)'
log_archive_dest_2 = 'SERVICE=mydb DB_UNIQUE_NAME=mydb VALID_FOR=(ONLINE_LOGFILE,PRIMARY_ROLE)'
log_archive_dest_state_1='enable'
log_archive_dest_state_2='enable'

db_file_name_convert='/u01/app/oracle/oradata/mydb/','/u01/app/oracle/oradata/mydbstb/'
log_file_name_convert='/u01/app/oracle/oradata/mydb/','/u01/app/oracle/oradata/mydbstb/'

fal_server='mydb'
fal_client='mydbstb'
standby_file_management='auto'


Create spfile for Standby Node:
Now connect to the standby database and create spfile for the standby database, using this newly created pfile.
For doing so, please follow the steps mentioned below:
[oracle@redhat2 ~]$ export ORACLE_SID=mydbstb
[oracle@redhat2 ~]$ sqlplus / as sysdba
SQL> create spfile from pfile='pfile_location/initsby.ora' ;

Start the database in nomount mode:
SQL> startup nomount


 Cloning the Standby Database:
Do this from the Standby Site ( redhat2 ).
From the standby host , duplicate the primary database as a standby using RMAN. As mentioned below:
[oracle@redhat2 ~]$ rman target sys/sys@mydb auxiliary sys/sys@mydbstb
In the rman prompt type the following::
RMAN> duplicate target database for standby ;


Place the Standby Database on Recovery Mode:
To place the standby database on recovery mode. Do the following:
SQL> alter database recover managed standby database using current logfile disconnect;


Enable Remote Archiving on Node1:
SQL> alter system set log_archive_dest_state_2='ENABLE' scope=both;


This finishes physical standby database creation.

No comments:

Post a Comment