Create RAC Standby Database for RAC Primary Database
This article speaks of creating a RAC physical standby database for RAC Primary database.
Primary and Standby databases are of 2 node RAC.
Primary Database : PRIM
DBNAME : PRIM
DB UNIQUE NAME : PRIM
Instances : PRIM1 on node1
PRIM2 on node2
Standby Database : SRPSTB
DBNAME : PRIM
DB UNIQUE NAME : SRPSTB
Instances : SRPSTB1 on drnode1
SRPSTB2 on drnode2
Database version: Oracle 11.2.0.1
Below are the steps to create a RAC standby database for a RAC primary database.
Step 1: Add the following standby parameters on the primary database.
log_archive_dest_1='location=use_db_recovery_file_dest valid_for=(all_logfiles,all_roles) db_unique_name=prim' log_archive_dest_2='service=srpstb valid_for=(online_logfiles,primary_role) db_unique_name=srpstb' fal_client='prim' #Oracle net service name of primary database fal_server='srpstb' #oracle net service name of standby database.
Step 2: Create a pfile of the primary database and copy this file to the standby server.
The contents of the pfile of primary database is as below. (This is the pfile taken from instance prim1 of primary DB.)
[oracle@node1 u02]$ cat initprim1.ora prim1.__db_cache_size=385875968 prim2.__db_cache_size=436207616 prim1.__java_pool_size=16777216 prim2.__java_pool_size=16777216 prim1.__large_pool_size=16777216 prim2.__large_pool_size=16777216 prim1.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment prim1.__pga_aggregate_target=520093696 prim2.__pga_aggregate_target=520093696 prim1.__sga_target=754974720 prim2.__sga_target=754974720 prim1.__shared_io_pool_size=0 prim2.__shared_io_pool_size=0 prim1.__shared_pool_size=318767104 prim2.__shared_pool_size=268435456 prim1.__streams_pool_size=0 prim2.__streams_pool_size=0 *.audit_file_dest='/u01/app/oracle/admin/prim/adump' *.audit_trail='db' *.cluster_database=true *.compatible='11.2.0.0.0' *.control_files='+DATA/prim/controlfile/current.260.826037247' *.db_block_size=8192 *.db_create_file_dest='+DATA' *.db_domain='' *.db_name='prim' *.db_unique_name='prim' *.db_recovery_file_dest_size=2147483648 *.db_recovery_file_dest='+FRA' *.diagnostic_dest='/u01/app/oracle' *.dispatchers='(PROTOCOL=TCP) (SERVICE=primXDB)' *.fal_client='prim' *.fal_server='srpstb' prim1.instance_number=1 prim2.instance_number=2 prim1.local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=node1-vip)(PORT=1521))))' prim2.local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=node2-vip)(PORT=1521))))' *.log_archive_dest_1='location=use_db_recovery_file_dest valid_for=(all_logfiles,all_roles) db_unique_name=prim' *.log_archive_dest_2='service=srpstb valid_for=(online_logfiles,primary_role) db_unique_name=srpstb' *.memory_target=1264582656 *.open_cursors=300 *.processes=150 *.remote_listener='node-scan:1521' *.remote_login_passwordfile='exclusive' prim2.thread=2 prim1.thread=1 prim2.undo_tablespace='UNDOTBS2' prim1.undo_tablespace='UNDOTBS1'
Step 3. Listener File contents on Primary Database server.
[oracle@node1 admin]$ cat listener.ora LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))) # line added by Agent LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))) # line added by Agent ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON # line added by Agent ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent SID_LIST_LISTENER= (SID_LIST= (SID_DESC= (ORACLE_HOME=/u01/app/oracle/product/11.2.0/db1) (SID_NAME=prim1) ) )
Step 4: TNS entries on primary database server.
### PRIMARY ENTRIES ###
PRIM = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = node-scan)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = prim) ) ) PRIM1 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = node1-vip)(PORT=1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = prim) (INSTANCE_NAME = prim1) ) ) PRIM2 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = node2-vip)(PORT=1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = prim) (INSTANCE_NAME = prim2) ) )
### Standby TNS ENTRIES ###
SRPSTB = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = drnode-scan)(PORT = 1521) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = srpstb) (UR = A) ) ) SRPSTB2 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = drnode2-vip)(PORT = 1521) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = srpstb) (UR = A) (INSTANCE_NAME = srpstb2) ) ) SRPSTB1 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = drnode1-vip)(PORT = 1521) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = srpstb) (UR = A) (INSTANCE_NAME = srpstb1) ) )
Step 5: Copy the above TNS entries to standby database server node drnode1.
Step 6: Copy the password file of any instance (“orapwprim1” or “orapwprim2”) of primary database located at “$ORACLE_HOME/dbs” location to
the standby database server node drnode1 location “$ORACLE_HOME/dbs” and rename it to “orapwsrpstb1”.
Step 7: On the standby database server, perpare the pfile for srpstb1 instance as initsrpstb1.ora .
Contents of initsrpstb1.ora File:
[oracle@drnode1 dbs]$ cat initsrpstb1.ora srpstb1.__db_cache_size=419430400 srpstb1.__java_pool_size=16777216 srpstb1.__large_pool_size=16777216 srpstb1.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment srpstb1.__pga_aggregate_target=520093696 srpstb1.__sga_target=754974720 srpstb1.__shared_io_pool_size=0 srpstb1.__shared_pool_size=285212672 srpstb1.__streams_pool_size=0 *.audit_file_dest='/u01/app/oracle/admin/srpstb/adump' *.audit_trail='db' *.cluster_database=false *.compatible='11.2.0.0.0' *.control_files='+DATA','+FRA' *.db_block_size=8192 *.db_create_file_dest='+DATA' *.db_name='prim' *.db_unique_name='srpstb' *.diagnostic_dest='/u01/app/oracle' *.dispatchers='(PROTOCOL=TCP) (SERVICE=srpstbXDB)' *.log_archive_dest_1='location=use_db_recovery_file_dest valid_for=(all_logfiles,all_roles) db_unique_name=srpstb' *.log_archive_dest_2='service=prim valid_for=(online_logfiles,primary_role) db_unique_name=prim' *.db_recovery_file_dest='+FRA' *.db_recovery_file_dest_size=2G *.memory_target=1264582656 *.open_cursors=300 *.processes=150 *.remote_listener='drnode-scan:1521' *.remote_login_passwordfile='EXCLUSIVE' srpstb1.undo_tablespace='UNDOTBS1' srpstb1.local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=drnode1-vip)(PORT=1521))))' srpstb1.fal_client='srpstb1' *.fal_server='prim'
Step 8: Set up the listener.ora file on the standby database server drnode1.
Contents of Listener.ora file on DRNODE1:
[oracle@drnode1 admin]$ cat listener.ora LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))) # line added by Agent LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))) # line added by Agent ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON # line added by Agent ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent SID_LIST_LISTENER= (SID_LIST= (SID_DESC= (ORACLE_HOME=/u01/app/oracle/product/11.2.0.1/db1) (SID_NAME=srpstb1) ) )
Step 9: Nomount the standby instance srpstb1 using the above pfile “initsrpstb1.ora”.
Step 10: Now connect to the Primary database as target database and standby database as auxiliary instance through RMAN. Make sure that the
Primary database is open.
[oracle@drnode1 ~]$ rman target sys/oracle@prim auxiliary sys/oracle@srpstb1 Recovery Manager: Release 11.2.0.1.0 - Production on Fri Oct 25 19:54:07 2013 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. connected to target database: PRIM (DBID=4118338878) connected to auxiliary database: PRIM (not mounted) RMAN> duplicate target database for standby from active database; Starting Duplicate Db at 25-OCT-13 using target database control file instead of recovery catalog allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=28 device type=DISK contents of Memory Script: { backup as copy reuse targetfile '/u01/app/oracle/product/11.2.0/db1/dbs/orapwprim2' auxiliary format '/u01/app/oracle/product/11.2.0.1/db1/dbs/orapwsrpstb1' ; } executing Memory Script Starting backup at 25-OCT-13 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=37 instance=prim2 device type=DISK Finished backup at 25-OCT-13 contents of Memory Script: { backup as copy current controlfile for standby auxiliary form at '+DATA/srpstb/controlfile/current.269.829771129'; restore clone controlfile to '+FRA/srpstb/controlfile/current.261.829771129' from '+DATA/srpstb/controlfile/current.269.829771129'; sql clone "create spfile from memory"; shutdown clone immediate; startup clone nomount; sql clone "alter system set control_files = ''+DATA/srpstb/controlfile/current.269.829771129'', ''+FRA/sr pstb/controlfile/current.261.829771129'' comment= ''Set by RMAN'' scope=spfile"; shutdown clone immediate; startup clone nomount; } executing Memory Script Starting backup at 25-OCT-13 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile copy copying standby control file output file name=/u01/app/oracle/product/11.2.0/db1/dbs/snapcf_prim2.f tag=TAG20131025T195848 RECID=2 STAMP=829771151 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:46 Finished backup at 25-OCT-13 Starting restore at 25-OCT-13 using channel ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: copied control file copy Finished restore at 25-OCT-13 sql statement: create spfile from memory Oracle instance shut down connected to auxiliary database (not started) Oracle instance started Total System Global Area 1269366784 bytes Fixed Size 2212976 bytes Variable Size 855640976 bytes Database Buffers 402653184 bytes Redo Buffers 8859648 bytes sql statement: alter system set control_files = ''+DATA/srpstb/controlfile/current.269.829771129'', ''+FRA/srpstb/controlfile/current.261.829771129'' comment= ''Set by RMAN'' scope=spfile Oracle instance shut down connected to auxiliary database (not started) Oracle instance started Total System Global Area 1269366784 bytes Fixed Size 2212976 bytes Variable Size 855640976 bytes Database Buffers 402653184 bytes Redo Buffers 8859648 bytes contents of Memory Script: { sql clone 'alter database mount standby database'; } executing Memory Script sql statement: alter database mount standby database contents of Memory Script: { set newname for clone tempfile 1 to new; switch clone tempfile all; set newname for clone datafile 1 to new; set newname for clone datafile 2 to new; set newname for clone datafile 3 to new; set newname for clone datafile 4 to new; set newname for clone datafile 5 to new; set newname for clone datafile 6 to new; backup as copy reuse datafile 1 auxiliary format new datafile 2 auxiliary format new datafile 3 auxiliary format new datafile 4 auxiliary format new datafile 5 auxiliary format new datafile 6 auxiliary format new ; sql 'alter system archive log current'; } executing Memory Script executing command: SET NEWNAME renamed tempfile 1 to +DATA in control file executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME Starting backup at 25-OCT-13 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile copy input datafile file number=00001 name=+DATA/prim/datafile/system.256.826037011 output file name=+DATA/srpstb/datafile/system.266.829771513 tag=TAG20131025T200453 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:45 channel ORA_DISK_1: starting datafile copy input datafile file number=00002 name=+DATA/prim/datafile/sysaux.257.826037013 output file name=+DATA/srpstb/datafile/sysaux.277.829771637 tag=TAG20131025T200453 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:55 channel ORA_DISK_1: starting datafile copy input datafile file number=00003 name=+DATA/prim/datafile/undotbs1.258.826037015 output file name=+DATA/srpstb/datafile/undotbs1.276.829771735 tag=TAG20131025T200453 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35 channel ORA_DISK_1: starting datafile copy input datafile file number=00005 name=+DATA/prim/datafile/example.264.826037271 output file name=+DATA/srpstb/datafile/example.275.829771771 tag=TAG20131025T200453 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35 channel ORA_DISK_1: starting datafile copy input datafile file number=00006 name=+DATA/prim/datafile/undotbs2.265.826037561 output file name=+DATA/srpstb/datafile/undotbs2.274.829771805 tag=TAG20131025T200453 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25 channel ORA_DISK_1: starting datafile copy input datafile file number=00004 name=+DATA/prim/datafile/users.259.826037015 output file name=+DATA/srpstb/datafile/users.273.829771831 tag=TAG20131025T200453 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25 Finished backup at 25-OCT-13 sql statement: alter system archive log current contents of Memory Script: { switch clone datafile all; } executing Memory Script datafile 1 switched to datafile copy input datafile copy RECID=2 STAMP=829771843 file name=+DATA/srpstb/datafile/system.266.829771513 datafile 2 switched to datafile copy input datafile copy RECID=3 STAMP=829771843 file name=+DATA/srpstb/datafile/sysaux.277.829771637 datafile 3 switched to datafile copy input datafile copy RECID=4 STAMP=829771843 file name=+DATA/srpstb/datafile/undotbs1.276.829771735 datafile 4 switched to datafile copy input datafile copy RECID=5 STAMP=829771843 file name=+DATA/srpstb/datafile/users.273.829771831 datafile 5 switched to datafile copy input datafile copy RECID=6 STAMP=829771843 file name=+DATA/srpstb/datafile/example.275.829771771 datafile 6 switched to datafile copy input datafile copy RECID=7 STAMP=829771843 file name=+DATA/srpstb/datafile/undotbs2.274.829771805 Finished Duplicate Db at 25-OCT-13
Step 11: Once the duplication is completed, close the RMAN prompt and connect to the standby database through SQL.
sqlplus sys/<password>@srpstb1 as sysdba
Check the status of the standby database by making sure it is in mount stage.
sql>select status,instance_name,database_role from v$instance,v$database;
Step 12: Now start the managed recovery process on the standby database.
sql>alter database recover managed standby database disconnect from session;
Step 13: Now check if the managed recovery process (MRP) has been started on the standby database or not.
SQL> select process,status,sequence#,thread# from v$managed_standby; PROCESS STATUS SEQUENCE# THREAD# ------- ------------ --------- ------- ARCH CONNECTED 0 0 ARCH CONNECTED 0 0 ARCH CONNECTED 0 0 ARCH CONNECTED 0 0 MRP0 WAIT_FOR_LOG 65 2 RFS IDLE 0 0 RFS IDLE 0 0 RFS IDLE 0 0 RFS IDLE 0 0 RFS IDLE 75 1 RFS IDLE 0 0 RFS IDLE 0 0 RFS IDLE 0 0 RFS IDLE 0 0 14 rows selected.
Here, the MRP has been started and is waiting for the log sequence# 39. If MRP is not started, then the above query would not show up the
MRP0 under the process column.
Step 14: On the primary database, perform a few log switches and check if the logs are applied to the standby database.
Primary Database Archive Sequence:
sqlplus sys/<password>@prim1 as sysdba SQL> select thread#,max(sequence#) from v$archived_log group by thread#; THREAD# MAX(SEQUENCE#) ------- ---------------- 1 76 2 67
Standby database SRPSTB1 archive sequence being applied:
sqlplus sys/<password>@srpstb1 as sysdba SQL> select thread#,max(sequence#) from v$archived_log where applied='YES' group by thread#; THREAD# MAX(SEQUENCE#) ------- ----------------- 1 75 2 67
Here, the maximum sequence# generated on the Primary database from instance 1 (prim1) is 76 and from instance 2 (prim2) is 67 and the maximum sequence# applied on the standby database for thread 1 is 75 and thread 2 is 67 which means that the standby database is in sync with the primary database.
Now lets add the 2nd instance srpstb2 to the Standby Database srpstb.
Step 15: Create a pfile from the standby instance srpstb1 to add the cluster parameters.
cluster_database=TRUE srpstb1.undo_tablespace='UNDOTBS1' srpstb2.undo_tablespace='UNDOTBS2' srpstb2.local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=drnode2-vip)(PORT=1521))))' srpstb1.instance_number=1 srpstb2.instance_number=2 srpstb1.thread=1 srpstb2.thread=2 srpstb1.fal_client='srpstb1' srpstb2.fal_client='srpstb2'
The new pfile required for the standby database cluster would look as below.
[oracle@drnode1 dbs]$ cat initsrpstb1.ora srpstb1.__db_cache_size=402653184 srpstb1.__java_pool_size=16777216 srpstb1.__large_pool_size=16777216 srpstb1.__pga_aggregate_target=520093696 srpstb1.__sga_target=754974720 srpstb1.__shared_io_pool_size=0 srpstb1.__shared_pool_size=285212672 srpstb1.__streams_pool_size=0 srpstb2.__db_cache_size=402653184 srpstb2.__java_pool_size=16777216 srpstb2.__large_pool_size=16777216 srpstb2.__pga_aggregate_target=520093696 srpstb2.__sga_target=754974720 srpstb2.__shared_io_pool_size=0 srpstb2.__shared_pool_size=285212672 srpstb2.__streams_pool_size=0 *.audit_file_dest='/u01/app/oracle/admin/srpstb/adump' *.audit_trail='DB' *.cluster_database=TRUE *.compatible='11.2.0.0.0' *.control_files='+DATA/srpstb/controlfile/current.269.829771129','+FRA/srpstb/controlfile/current.261.829771129'#Set by RMAN *.db_block_size=8192 *.db_create_file_dest='+DATA' *.db_name='prim' *.db_recovery_file_dest='+FRA' *.db_recovery_file_dest_size=2G *.db_unique_name='srpstb' *.diagnostic_dest='/u01/app/oracle' *.dispatchers='(PROTOCOL=TCP) (SERVICE=srpstbXDB)' *.fal_client='srpstb1' *.fal_server='prim' srpstb1.local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCO=TCP)(HOST=drnode1-vip)(PORT=1521))))' srpstb2.local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=drnode2-vip)(PORT=1521))))' *.log_archive_dest_1='location=use_db_recovery_file_dest valid_for=(all_logfiles,all_roles) db_unique_name=srpstb' *.log_archive_dest_2='service=prim valid_for=(online_logfiles,primary_role) db_unique_name=prim' *.log_buffer=8491008# log buffer update *.memory_target=1216M *.open_cursors=300 *.processes=150 *.query_rewrite_enabled='TRUE' *.remote_login_passwordfile='EXCLUSIVE' srpstb1.undo_tablespace='UNDOTBS1' srpstb2.undo_tablespace='UNDOTBS2' srpstb1.instance_number=1 srpstb2.instance_number=2 srpstb1.thread=1 srpstb2.thread=2 srpstb1.fal_client='srpstb1' srpstb2.fal_client='srpstb2' *.fal_server='prim'
Step 16: Shutdown the instance srpstb1, mount it using the newly above pfile, create an spfile to be placed in the shared location (ASM
diskgroup, as it is being shared by both the instances srpstb1 and srpstb2.)
SQL> create spfile='+DATA/SRPSTB/spfilesrpstb.ora' from pfile; File created.
Step 17: Create a new pfile initsrpstb1.ora in drnode1 located at $ORACLE_HOME/dbs with just one entry to point to the spfile location.
[oracle@drnode1 dbs]$ cat initsrpstb1.ora SPFILE='+DATA/SRPSTB/spfilesrpstb.ora'
Step 17: Copy the password file of srpstb1 (orapwsrpstb1) to drnode2 location “$ORACLE_HOME/dbs” and rename it as orapwsrpstb2.
Step 18: Copy the newly created pfile (initsrpstb1.ora) fto drnode2 location “$ORACLE_HOME/dbs” and rename it as initsrpstb2.ora
Step 19: Mount both srpstb1 and srpstb2 instances.
Step 20: Start MRP on any one instance using the below query.
SQL> alter database recover managed standby database disconnect from session;
Step 21: Check the max archive sequence generated on primary and compare it with the max archive sequence applied on the standby.
Primary:
SQL> select thread#,max(sequence#) from v$archived_log group by thread#;
Standby:
SQL> select thread#,max(sequence#) from v$archived_log where applied='YES' group by thread#;
Step 22: The next step would be to add the standby database SRPSTB to the cluster.
[oracle@drnode1 ~]$ srvctl add database -d srpstb -o /u01/app/oracle/product/11.2.0.1/db1 -r PHYSICAL_STANDBY -s MOUNT
Step 23: Now, we also need to add the instances entrires to the standby database.
[oracle@drnode1 ~]$ srvctl add instance -d srpstb -i srpstb1 -n drnode1 [oracle@drnode1 ~]$ srvctl add instance -d srpstb -i srpstb2 -n drnode2
Step 24: Now check the status of the standby database using srvctl.
[oracle@drnode1 ~]$ srvctl start database -d srpstb [oracle@drnode1 ~]$ srvctl status database -d srpstb Instance srpstb1 is running on node drnode1 Instance srpstb2 is running on node drnode2
Here we go !!
COPYRIGHT
© Shivananda Rao P, 2012 to 2018. Unauthorized use and/or duplication of this material without express and written permission from this blog’s author and/or owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to Shivananda Rao and http://www.shivanandarao-oracle.com with appropriate and specific direction to the original content.
DISCLAIMER
The views expressed here are my own and do not necessarily reflect the views of any other individual, business entity, or organization. The views expressed by visitors on this blog are theirs solely and may not reflect mine.
Asking questions are truly good thing if
you are not understanding anything fully, however this piece of writing gives fastidious understanding
even.