Create 11g standby without backup

In 11g, Oracle has simplified the building of standby further so that it can be built out without taking an ad-hoc backup against primary database.  The method is called 'active database'.  This is an additional option especially for small databases.  
Below are the steps I typically follow for building out my standbys in 11g.

Before building out your standby, ensure that the database has force logging enabled in your primary database.

     ALTER DATABASE FORCE LOGGING;

1. Either configure your listener under the ORACLE_HOME for the standby (typically using NETCA) or if you are using 11gR2 RAC, you can use the Grid Infrastructure listener.ora to add your entries.  Configure listener.ora with your standby SID and reload listener.
(example)
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /orabase/product/11.2.0/db_1)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = stbydb)
      (SID_NAME = stbydb)
      (ORACLE_HOME = /orabase/product/11.2.0/db_1)
    )
  )
    lsnrctl reload LISTENER


3. Modify tnsnames.ora in $TNS_ADMIN on both primary and standby locations to include both your standby database TNS entry and the primary database TNS entry. 

 (example)

    stbydb =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = < standby_hostname>)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = stbydb)
    )
  )
prmrydb =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = <primary_hostname>)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = prmrydb)
    )
  )

4.  Test connectivity both ways between both db instances via tnsping.
(example)
     tnsping stbydb
     tnsping prmrydb

5.  Pre-create your directory structure for the standby database under the $ORACLE_BASE/admin.
(example)
    mkdir -p $ORACLE_BASE/admin/stbydb/adump

6.  Copy oracle password file from production to your standby server under $ORACLE_HOME/dbs, also create dummy parameter file for auxiliary instance.


echo "db_name=stbydb" > $ORACLE_HOME/dbs/initstbydb.ora
echo "memory_target=<primary's_memory_target>" >> $ORACLE_HOME/dbs/initstbydb.ora


7.  Create stby.cmd file for RMAN to build out the standby across the network.
(example)

connect target sys/oracle@prmrydb;
connect auxiliary sys/oracle@stbydb;
run {
allocate channel prm1 type disk;
allocate channel prm2 type disk;
allocate channel prm3 type disk;
allocate channel prm4 type disk;
allocate channel prm5 type disk;
allocate auxiliary channel stb1 type disk;
allocate auxiliary channel stb2 type disk;
allocate auxiliary channel stb3 type disk;
allocate auxiliary channel stb4 type disk;
allocate auxiliary channel stb5 type disk;
duplicate target database for standby from active database
dorecover
spfile
set 'db_unique_name'='stbydb'
set 'control_files'='+DG01'
set db_create_file_dest='+DG01'
set db_create_online_log_dest_1='+DG01'
set db_recovery_file_dest='+FRA01'
set db_recovery_file_dest_size='15G'
set cluster_database='FALSE'
set audit_file_dest='$ORACLE_BASE/admin/stbydb/adump'
set instance_number='1'
SET FAL_CLIENT='stbydb'
SET FAL_SERVER='prmrydb'
SET service_names='stbydb'
SET log_archive_config='DG_CONFIG=(prmrydb,stbydb)'
SET standby_file_management='AUTO'
nofilenamecheck;
}


8.  Startup the instance in NOMOUNT state and then start the RMAN duplicate job.
(example)

     nohup rman cmdfile stby.cmd log stby.log &

9.  After standby creation has finished, modify primary database parameters for standby sync up.

ALTER SYSTEM SET log_archive_config='DG_CONFIG=(prmrydb,stbydb)';
ALTER SYSTEM SET log_archive_dest_2='SERVICE=stbydb valid_for=(online_logfiles,primary_role) DB_UNIQUE_NAME=stbydb';
ALTER SYSTEM SET fal_client='prmrydb';
ALTER SYSTEM SET fal_server='stbydb';
ALTER SYSTEM SET standby_file_management='AUTO';
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2='enable';
  
10.  Bounce the standby database and enable active recovery on standby.

      alter database recover managed standby database disconnect;


If you would like oracle to automatically delete your archivelogs after being applied to standby, do the following:


1. alter system set log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST';
2. rman target /
   CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;




When the db_recovery_file_dest_size hits 100%, oracle will begin automatically deleting applied archivelogs.  This saves you have to run a job to delete them. 


Oracle will precreate your standby redologs under the ORACLE_HOME/dbs directory if none exist currently in the primary database.
See highlighted below:



    GROUP# MEMBER
---------- --------------------------------------------------
         1 +DG01/stbydb/onlinelog/group_1.577.748263071
         2 +DG01/stbydb/onlinelog/group_2.578.748263073
         3 +DG01/stbydb/onlinelog/group_3.579.748263073
         4 +DG01/stbydb/onlinelog/group_4.580.748263073
         5 +DG01/stbydb/onlinelog/group_5.581.748263075
         6 +DG01/stbydb/onlinelog/group_6.582.748263075
         7 +DG01/stbydb/onlinelog/group_7.583.748263077
         8 +DG01/stbydb/onlinelog/group_8.584.748263077

         9 /orabase/product/11.2.0/db_1/dbs/srl1.f
        10 /orabase/product/11.2.0/db_1/dbs/srl2.f
        11 /orabase/product/11.2.0/db_1/dbs/srl3.f


    GROUP# MEMBER
---------- --------------------------------------------------
        12 /orabase/product/11.2.0/db_1/dbs/srl4.f
        13 /orabase/product/11.2.0/db_1/dbs/srl5.f
        14 /orabase/product/11.2.0/db_1/dbs/srl6.f
        15 /orabase/product/11.2.0/db_1/dbs/srl7.f
        16 /orabase/product/11.2.0/db_1/dbs/srl8.f
        17 /orabase/product/11.2.0/db_1/dbs/srl9.f
        18 /orabase/product/11.2.0/db_1/dbs/srl10.f




11. You will need to drop/recreate or create all the standby redo logs.  
Ex.
 alter database drop logfile group 9;
 alter database add standby logfile thread 1 group 11 '+DG01' SIZE 200M;




If you want to use dataguard broker for primary database and it's running on RAC, by default the dg_broker_config_file1 and dg_broker_config_file2 are set to point to the Oracle Home.  You want to change that to point to a shared location, either NFS mount or ASM.
ex. 

SQL> alter system set dg_broker_config_file1='+DG01/prmrydb/dr1_prmrydb
.dat';
SQL> alter system set dg_broker_config_file2='+DG01/prmrydb/dr2_prmrydb
.dat';

To configure dg broker so that it can seamlessly startup/shutdown, failover/switchover your databases without manual intervention, configure the listener to include entry for DGMGRL.
ex.


SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
    (SDU=32767)
      (GLOBAL_DBNAME = stbydb)
      (ORACLE_HOME = /orabase/product/11.1.0.7.0/db_1)
      (SID_NAME = stbydb)
    )
    (SID_DESC =
    (SDU=32767)
      (GLOBAL_DBNAME = stbydb_DGMGRL)
      (ORACLE_HOME = /orabase/product/11.1.0.7.0/db_1)
      (SID_NAME = stbydb)
    )
  )

Comments

Popular posts from this blog

ORA-17630: Mismatch in the remote file protocol version client 2 server 3

RMAN-10038: database session for channel prm3 terminated unexpectedly

ORA-00338: log {n} of thread {n} is more recent than control file