About Me

Monday 31 October 2011

DATAGUARD CONFIGURATION


Suppose we have two servers dba1 and dba2.On the first server dba1 we have production databas
and on the second server we want to create stand by database .In order to configure dataguard follow
the given steps. 

1.create a cross network between two servers production
and standby


( PRODUCTION SIDE )

  ]$ vi listener.ora

  prod =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = dba1)(PORT = 3456))
      )
    )
  )

SID_LIST_prod =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = dharam)
      (ORACLE_HOME = /oraeng/app/oracle/product/11.2.0)
    )
  )

After configure listener start the listener

  ]$ lsnrctl start prod


( STANDBY SIDE )

  ]$ vi tnsnames.ora

  to_prod =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST=dba1)(PORT=3456))
    )
    (CONNECT_DATA =
      (SID = dharam)
    )
  )

  ]$ tnsping to_prod

  ]$ vi listener.ora
 
  stand =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = dba2)(PORT = 4567))
      )
    )
  )

SID_LIST_stand =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = dharam)
      (ORACLE_HOME = /oraeng/app/oracle/product/11.2.0)
    )
  )

   ]$ lsnrctl start stand


( PRODUCTION SIDE )

   ]$ vi tnsnames.ora

   to_stand =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST=dba2)(PORT=4567))
    )
    (CONNECT_DATA =
      (SID = dharam)
    )
  )

   ]$ tnsping to_stand

2.Create a separate directory at production

]$ mkdir  /disk1/oradata/dharam/dg

]$ cp   *.dbf   *.log   /disk1/oradata/dharam/dg
 
  dbs]$ orapwd file=orapw$ORACLE_SID  password=sys  force=y

]$ cp orapw$ORACLE_SID   /disk1/oradata/dharam/dg

3.In pfile at production add these parameters 
   ]$ vi $ORACLE_HOME/dbs/init$ORACLE_SID.ora

log_archive_dest_1='location= /disk1/oradata/dharam/arch'
log_archive_dest_2='service= to_stand lgwr sync affirm    reopen=5’
standby_archive_dest= /disk1/oradata/dharam/arch
standby_file_management = auto

]$ cp init$ORACLE_SID.ora /disk1/oradata/dharam/dg

 ]$ sqlplus / as sysdba


4.now we will create stand by controlfile.

sys> startup mount

sys> alter database create standby controlfile as
          ‘/disk1/oradata/dharam/dg/stand.ctl’;


5.Bring all the CRD files from production to stand by server 

STANDBY SIDE

]$ export ORACLE_SID=dharam

 
]$ mkdir /disk1/oradata/dharam

we need to bring all the files from production server to stand by server either through ftp or any other way . Then copy parameterfile and password file to dbs location of standby database .

]$ cp init$ORACLE_SID.ora orapw$ORACLE_SID  $ORACLE_HOME/dbs

Open the pfile and give controlfile name as stand.ctl and service=to_prod 

6.Mounting stand by database

]$ sqlplus / as sysdba

sys > startup nomount
  
sys > alter database mount standby database;

 Keep standby database in MRM mode and take some log switches at production side.
  
sys>alter database recover managed standby database;

7.Now check the consistency of standby database

On production

sys>alter system switch logfile;

sys>archive log list;

On standby

sys>archive log list;

archive log sequence should be same.

sys > select name, applied from v$archived_log;

If all archive log files are applying, then configuration is fine.

1 comment:

  1. nice xplanation sir.sir try to post ur real time issues it will help me lot

    ReplyDelete