by http://webgeektutorials.blogspot.com

Sunday, February 20, 2011

Physical Data Guard scenario in 10G on Linux

This document has been created with step-by-step instructions on how
to create a Data Guard Physical Standby environment, derived from the
10G documentation. Although, this setup was tested with Linux, the
procedure would be the same for any flavor of Unix.

Creating a Physical Data Guard scenario in 10G on Linux.
==========================================================
1.        Primary host: stdg2
           Standby host: stdg1

           Platform: Linux Redhat AS 
           Kernel: 2.4.9-e.24

           Primary Set up on host stdg2
           ORACLE_SID=v10g

 Initialization parameters (PRIMARY)
 ==============================
        *. control_files='/u02/admin/v10g/datafiles/control01.ctl'
        *.log_archive_config='DG_CONFIG=(v10g_stdg2,v10g_stdg1)'
        *.log_archive_dest_1='LOCATION=/u02/admin/v10g/v10garch/  VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
       *.db_unique_name=v10g_stdg2'
       *.log_archive_dest_2='SERVICE=v10g_stdg1
  VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
  DB_UNIQUE_NAME=v10g_stdg1 LGWR ASYNC REOPEN=10'
               
        *.log_archive_dest_state_1='enable'
        *.log_archive_dest_state_2='enable'
        *.db_unique_name='v10g_stdg2'
               
        *.FAL_CLIENT='v10g_stdg2'
        *.FAL_SERVER='v10g_stdg1'

        *.standby_archive_dest='/u02/admin/v10g/v10garch'
        *.standby_file_management='auto'
        *.remote_login_passwordfile='EXCLUSIVE'


2.     Place the primary datbase in ARCHIVELOG mode.
              SQL>SHUTDOWN IMMEDIATE
              SQL>STARTUP MOUNT
              SQL>ALTER DATABASE ARCHIVELOG;
              SQL>ALTER DATABASE OPEN;
              SQL>ARCHIVE LOG LIST;

3.          Creating the physical standby.

  -              Take a backup of the primary. (Cold backup was used)
  -              SQL>STARTUP MOUNT (Primary)
  -              SQL>ALTER DATABASE CREATE STANDBY CONTROLFILE
                              AS ‘<PATH>/STDBY.CTL’;
  -              SQL>ALTER DATABASE OPEN;
  -              Create a pfile for the standby database
  -              SQL>CREATE PFILE=’<PATH>/INITSTDBY.ORA’ FROM SPFILE;

            Initialization parameter(STANDBY)
            ==================================
              *.control_files='/u02/admin/v10g/datafiles/standby.ctl'
              *.log_archive_config='DG_CONFIG=(v10g_stdg2,v10g_stdg1)'
              *.log_archive_dest_1='LOCATION=/u02/admin/v10g/v10garch/  VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
              *.db_unique_name=v10g_stdg1'
              *.log_archive_dest_2='SERVICE=v10g_stdg2
  VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
  DB_UNIQUE_NAME=v10g_stdg2 LGWR ASYNC REOPEN=10'
               
              *.log_archive_dest_state_1='enable'
              *.log_archive_dest_state_2='enable'
              *.db_unique_name='v10g_stdg1'

              *.FAL_CLIENT='v10g_stdg1'
              *.FAL_SERVER='v10g_stdg2'

              *.standby_archive_dest='/u02/admin/v10g/v10garch'
              *.standby_file_management='auto'
              *.remote_login_passwordfile='EXCLUSIVE'

Set up the listeners (Net Services)

Primary:

LISTENER.ORA
LISTENER =
                (DESCRIPTION_LIST =
                (DESCRIPTION =
                (ADDRESS_LIST =
                              (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
                              )
                              (ADDRESS_LIST =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 138.1.137.235)(PORT = 1521))
  )
  )
  )

SID_LIST_LISTENER =
  (SID_LIST =
  (SID_DESC =
  (SID_NAME = PLSExtProc)
  (ORACLE_HOME = /u01/oracle/product/10g)
  (PROGRAM = extproc)
  )
  (SID_DESC =
  (GLOBAL_DBNAME = v10g)
(ORACLE_HOME = /u01/oracle/product/10g)
  (SID_NAME = v10g)
  )
)

TNSNAMES.ORA:

v10g_stdg1 =
  (DESCRIPTION =
  (ADDRESS_LIST =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 138.1.137.234)(PORT = 1521))
  )
  (CONNECT_DATA =
  (SERVER = DEDICATED)
  (SERVICE_NAME = v10g)
  )
  )
v10g_stdg2 =
  (DESCRIPTION =
  (ADDRESS_LIST =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 138.1.137.235)(PORT = 1521))
  )
  (CONNECT_DATA =
  (SERVER = DEDICATED)
  (SERVICE_NAME = v10g)
  )

NOTE: For the standby make sure you change the ip (HOST) from .234 to .235 appropriately

4.          Create the spfile on the standby from the pfile moved from the primary.

              SQL>CREATE SPFILE=’?/DBS/spfile<sid>.ora
              FROM PFILE=’INITSTDBY.ORA’;

              SQL>STARTUP MOUNT;
              SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;


5.          Check to see if the redo from the primary is being shipped to the standby
 
              On the primary do the following:

  -         SQL>ALTER SYSTEM SWITCH LOGFILE;

  -          SQl>SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME  FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

              SEQUENCE# FIRST_TIM NEXT_TIME
              ---------- --------- ---------
                71 15-AUG-10 15-AUG-10
                72 15-AUG-10 15-AUG-10
                73 15-AUG-10 15-AUG-10
        74 15-AUG-10 15-AUG-10

  Physical Standby:

  SQL>SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME
                 FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

              SEQUENCE# FIRST_TIM NEXT_TIME
              ---------- --------- ---------
 
                71 15-AUG-10 15-AUG-10
                72 15-AUG-10 15-AUG-10
                73 15-AUG-10 15-AUG-10
                74 15-AUG-10 15-AUG-10

6.          Verify if the archived logs are applied successfully on the standby

              SQL>SELECT SEQUENCE#,APPLIED FROM
  V$ARCHIVED_LOG ORDER BY SEQUENCE#;
              SEQUENCE# APP
              ---------- ---
                68 YES
                69 YES
                70 YES
                71 YES
                72 YES
                73 YES
                74 YES


Standby Redo Logs (SRLs)
=========================
This is similar to redo logs except that a standby log is used only when the database is in standby mode.

NOTE: The ARCHIVER (ARCn) or the (LGWR) process on the primary can transmit redo data directly to standby logfile.
(The details of SRL's is not discussed in this document)

To create a standby logfile:

- Stop the redo apply on the standby

         Alter database recover managed standby database cancel;

- Create the SRL’s 3 of them on the standby.
         SQL>alter database add standby logfile '/u02/admin/v10g/srldest/srl_1.log' size 10m;

- Restart the redo apply;

No comments:

Post a Comment