Step by Step to Configure Data-guard 11g on RHEL6.2

I am writing this blog to show step by step process of configuring data-guard in a simple process. As per my knowledge people who were new to data-guard find it very difficult to configure but seriously it is very easy.

First I would like to explain my environment , after then I will give simple steps the followed by details steps.


My environment:
============

OS : RHEL6.2
Database Version : 11.2.0.4
VM : Oracle VM

Node 1: test1.oracle.com
Node 2: test2.oracle.com

Primary database name : orcl
Stand-by database name : orcl_stby

step
1: Preparing  you environment by making sure you were able to ping from both the nodes
step 2: Please install oracle software on node 2 and then configure listener
step 3: Now test the defined connection string from both the nodes
step 4: Now come to primary node and login to the database
step 5: Define the required parameters on primary node to setup dataguard
step 6: Take the backup of the primary database control file
step 7: Now shutdown the database and take either cold backup or rman backup
step 8: Now copy the password file of the primary database for standby database
step 9: Now move the password file ,control file ,backup of the database,parameter file to standby node
step 10: Create directory structure at  the stand by side
step 11: prepare the parameter file for the stand by database
step 12: now start the database in the mount mode
step 13: Now restore the database using RMAN or RMAN duplicate or restore CRD files
step 14: Now start the MRP process
step 15: Now create stand by redo logs at the primary side and make sure you have extra group
step 16: now switch the redo logs
step 17: Now you can see you DR in sync with primary




TNS details:
--------------

Primary : test1_orcl
Standby : test2_stby

Make sure on both the nodes you update the tnsnames.ora with above  entries

Important Parameters to be noticed:
==========================

DB_NAME                            – Must be same on primary and on all standby
DB_UNIQUE_NAME          – Must be different on primary and all standby

LOG_ARCHIVE_CONFIG   – This parameter is used to define db unique names of  both primary and standby
eg:
DG_CONFIG=(orcl,orcl_stby) -> at primary
 DG_CONFIG=(orcl_stby,orcl) -> at stand by

LOG_ARCHIVE_DEST_n   – This parameter is need to define archive locations of both primary and stand by along with the service
log_archive_dest_2='SERVICE=test2_stby NOAFFIRM ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcl_stby'; - at primary side

LOG_ARCHIVE_DEST_STATE_n        – Define state of archiving (ENABLE or DEFER)
                             defer means archive will not be shipped from primary to stand by

REMOTE_LOGIN_PASSWORDFILE    – Must be in EXCLUSIVE mode
FAL_SERVER                                        – Use for archivelog gap resolution (required only in physical standby server)
DB_FILE_NAME_CONVERT                 – Required when directory structure is different datafile
LOG_FILE_NAME_CONVERT               – Required when directory structure is different logfile

Above are required only when we use different directory structure of primary and standby in my case I am not using as I am using same directory structure 

STANDBY_FILE_MANAGEMENT          – Keep auto to create file automatically on standby




lets start:
=======

1-> make sure archiving enabled at primary

SQL> show parameter db_name

db_name                              string      orcl
db_unique_name                 string      orcl








2-> ENABLE FORCE LOGGING

SQL> SELECT NAME,FORCE_LOGGING FROM V$DATABASE;

NAME      FOR
--------- ---
ORCL      YES


If no then execute

Alter database enable force logging;


3->Now define the parameters for the DG to configure

ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(orcl,orcl_stby)';
alter system set log_archive_dest_2='SERVICE=test2_stby NOAFFIRM ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcl_stby';
alter system set log_archive_dest_state_2=enable;
alter system set log_archive_format='%t_%s_%r.arc' scope=spfile;
alter system set log_archive_max_processes=30;
alter system set remote_login_passwordfile=exclusive scope=spfile;
alter system set fal_server=orcl_stby;
alter system set fal_client=orcl;
alter system set standby_file_management=auto;



4-> verify the listener.ora file

test1_orcl =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = test1.oracle.com)(PORT = 1529))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl.oracle.com)
      (SID_NAME = orcl)
    )
  )

test2_stby =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = test2.oracle.com)(PORT = 1522))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl.oracle.com)
      (SID_NAME = orcl)
    )
  )

5-> Now lets do the backup 

RMAN target /
rman> backup database plus archivelog;

6-> create control file for stand by database 
alter database create standby controlfile as '/u02/stndbyorcl.ctl';

7-> create pfile from spfile 

8-> Now edit  the pfile and make the below changes 

*.db_unique_name='orcl_stby'
 *.fal_server='orcl';
 *.fal_client='orcl_stby'
 *.log_archive_dest_2='SERVICE=test1_orcl NOAFFIRM ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcl'


9-> Now copy the parameter file , control file , password file and backup files or pieces to stand by server 


NOW lets come to node 2 or stand by server:
================================

set the environment
update the /etc/oratab file
start the database in nomount state
now create the spfile from pfile



+ASM:/u02/app/11.2.0/grid:N
clone:/u01/app/oracle/product/11.2.0/dbhome_1:N
orcl:/u01/app/oracle/product/11.2.0/dbhome_1:N

[oracle@test2 trace]$ . oraenv
ORACLE_SID = [orcl] ? orcl
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 is /u01/app/oracle
[oracle@test2 trace]$


SQL> startup pfile='/u02/FRA/stypfile.ora' nomount;
ORACLE instance started.
Total System Global Area  855982080 bytes
Fixed Size                  2218152 bytes
Variable Size             645924696 bytes
Database Buffers          205520896 bytes
Redo Buffers                2318336 bytes


11-> now connect to RMAN and the restore the database

rman target /
rman > restore database;



 Create standby redolog file to Primary and DR for the user of switch over, It should be match the configuration of the primary server.
Note: Create one additional standby redolog file on both.

AT primary:
==========




AT standby:
=========





NOW start the MRP process

 ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;


In case if you want to stop the MRP 

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL; 



After doing above steps now check the DR GAP 

SQL> show parameter uniq

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_unique_name                       string      orcl_stby
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            ?/dbs/arch
Oldest online log sequence     45
Next log sequence to archive   0
Current log sequence           50
SQL>




At primary :
========

SQL> show parameter uniq

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_unique_name                       string      orcl
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     48
Next log sequence to archive   50
Current log sequence           50
SQL>


NOTE: 
=====

To restore a DR you can use RMAN restore by copying the backup pieces from primary to stand by 
or
Instead of copying you can take duplicate rman backup from active database with out taking backup 
Ref : dbclone which I have posted 
or 
take a cold backup and then move the CRD files to stand by location 

You can verify the DB roles as below 

SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
ORCL      MOUNTED              PHYSICAL STANDBY

SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
ORCL      READ WRITE           PRIMARY


Cheers!! DR configuration is done 


Thanks,
Satya



Comments

Popular posts from this blog

Understanding Terraform

How to make CRS and ASM not to restart after server reboot

How to repair ASM disk header