Martins Blog

Trying to explain complex things in simple terms

RAC 12c enhancements: adding an additional SCAN-part 3

Posted by Martin Bach on May 9, 2014

Travel time can be writing time and while sitting in the departure lounge waiting for my flight I use the opportunity to add part 3 of the series. In the previous two parts you could read how to add a second SCAN and the necessary infrastructure to the cluster. Now it is time to create the standby database. It is assumed that a RAC One Node database has already been created on the primary cluster and is in archivelog mode.

Static Registration with the Listeners

The first step is to statically register the databases with their respective listeners. The example below is for the primary database first and standby next, it is equally applicable to the standby. The registration is needed during switchover operations when the broker restarts databases as needed. Without static registration you cannot connect to the database remotely while it is shut down.

# static registration on the primary cluster-$GRID_HOME/network/admin/listener.ora
SID_LIST_LISTENER_DG=
  (SID_LIST=
    (SID_DESC=
      (GLOBAL_DBNAME=RON)
      (ORACLE_HOME=/u01/app/oracle/product/12.1.0.1/dbhome_1)
      (SID_NAME=pri_1)
    )
    (SID_DESC=
      (GLOBAL_DBNAME=RON)
      (ORACLE_HOME=/u01/app/oracle/product/12.1.0.1/dbhome_1)
      (SID_NAME=pri_2)
    )

    (SID_DESC=
      (GLOBAL_DBNAME=RON_DGMGRL)
      (ORACLE_HOME=/u01/app/oracle/product/12.1.0.1/dbhome_1)
      (SID_NAME=pri_1)
    )
    (SID_DESC=
      (GLOBAL_DBNAME=RON_DGMGRL)
      (ORACLE_HOME=/u01/app/oracle/product/12.1.0.1/dbhome_1)
      (SID_NAME=pri_2)
    )
  )

# static registration on the standby cluster-$GRID_HOME/network/admin/listener.ora
SID_LIST_LISTENER_DG=
  (SID_LIST=
    (SID_DESC=
      (GLOBAL_DBNAME=rondg)
      (ORACLE_HOME=/u01/app/oracle/product/12.1.0.1/dbhome_1)
      (SID_NAME=sby_1)
    )
    (SID_DESC=
      (GLOBAL_DBNAME=rondg)
      (ORACLE_HOME=/u01/app/oracle/product/12.1.0.1/dbhome_1)
      (SID_NAME=sby_2)
    )

    (SID_DESC=
      (GLOBAL_DBNAME=rondg_DGMGRL)
      (ORACLE_HOME=/u01/app/oracle/product/12.1.0.1/dbhome_1)
      (SID_NAME=sby_1)
    )
    (SID_DESC=
      (GLOBAL_DBNAME=rondg_DGMGRL)
      (ORACLE_HOME=/u01/app/oracle/product/12.1.0.1/dbhome_1)
      (SID_NAME=sby_2)
    )
  )

The static listener registration has to be performed on each cluster node, primary and standby cluster alike.

Database Duplication-Creating the Physical Standby

With the listener registration complete you can start the duplication. I am using backup-based duplication here, you could equally go for a duplication from active database. To be able to perform the network duplication you have to have a backup first. I created it on the primary:

RMAN> backup incremental level 0 database format '/u01/oraback/%U';

Starting backup at 28-APR-14
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00003 name=+DATA/RON/DATAFILE/sysaux.257.838874315
input datafile file number=00006 name=+DATA/RON/DATAFILE/users.259.838874605
channel ORA_DISK_1: starting piece 1 at 28-APR-14
channel ORA_DISK_2: starting incremental level 0 datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
input datafile file number=00001 name=+DATA/RON/DATAFILE/system.258.838874441
input datafile file number=00004 name=+DATA/RON/DATAFILE/undotbs1.260.838874611
input datafile file number=00008 name=+DATA/RON/DATAFILE/undotbs2.268.838875559
channel ORA_DISK_2: starting piece 1 at 28-APR-14
channel ORA_DISK_1: finished piece 1 at 28-APR-14
piece handle=/u01/oraback/0pp6r8f8_1_1 tag=TAG20140428T044110 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:48
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00010 name=+DATA/RON/DD7D8C1D4C234B38E04325AAE80AF577/DATAFILE/sysaux.272.838876477
input datafile file number=00011 name=+DATA/RON/DD7D8C1D4C234B38E04325AAE80AF577/DATAFILE/users.275.838876481
channel ORA_DISK_1: starting piece 1 at 28-APR-14
channel ORA_DISK_2: finished piece 1 at 28-APR-14
piece handle=/u01/oraback/0qp6r8f8_1_1 tag=TAG20140428T044110 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:53
channel ORA_DISK_2: starting incremental level 0 datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
input datafile file number=00012 name=+DATA/RON/DD7D8C1D4C234B38E04325AAE80AF577/DATAFILE/example.273.838876479
input datafile file number=00009 name=+DATA/RON/DD7D8C1D4C234B38E04325AAE80AF577/DATAFILE/system.274.838876479
channel ORA_DISK_2: starting piece 1 at 28-APR-14
channel ORA_DISK_1: finished piece 1 at 28-APR-14
piece handle=/u01/oraback/0rp6r8gp_1_1 tag=TAG20140428T044110 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:29
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=+DATA/RON/DD7C48AA5A4404A2E04325AAE80A403C/DATAFILE/sysaux.265.838874953
channel ORA_DISK_1: starting piece 1 at 28-APR-14
channel ORA_DISK_2: finished piece 1 at 28-APR-14
piece handle=/u01/oraback/0sp6r8h1_1_1 tag=TAG20140428T044110 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:25
channel ORA_DISK_2: starting incremental level 0 datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
input datafile file number=00005 name=+DATA/RON/DD7C48AA5A4404A2E04325AAE80A403C/DATAFILE/system.266.838874953
channel ORA_DISK_2: starting piece 1 at 28-APR-14
...
channel ORA_DISK_2: finished piece 1 at 28-APR-14
piece handle=/u01/oraback/0up6r8ht_1_1 tag=TAG20140428T044110 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:25
Finished backup at 28-APR-14

Starting Control File and SPFILE Autobackup at 28-APR-14
piece handle=+RECO/RON/AUTOBACKUP/2014_04_28/s_846045788.270.846045815 comment=NONE
Finished Control File and SPFILE Autobackup at 28-APR-14

RMAN> backup current controlfile for standby;

Starting backup at 28-APR-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=282 instance=pri_1 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=43 instance=pri_1 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including standby control file in backup set
channel ORA_DISK_1: starting piece 1 at 28-APR-14
channel ORA_DISK_1: finished piece 1 at 28-APR-14
piece handle=/u01/oraback/10p6rafh_1_1 tag=TAG20140428T051528 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 28-APR-14

Starting Control File and SPFILE Autobackup at 28-APR-14
piece handle=+RECO/RON/AUTOBACKUP/2014_04_28/s_846047742.271.846047749 comment=NONE
Finished Control File and SPFILE Autobackup at 28-APR-14

RMAN>

Don’t forget to backup the current controlfile for a standby database – that’s immensely important for backup-based duplication but will be taken care of by the duplication “from active database”. Once the backup is created, ensure it is available on the standby host. In my case I am using the same backup location on the primary as well as on the standby. Being a good citizen and because I want test active duplication from backup later I created a new TNS entry in /u01/app/oracle/product/12.1.0.1/dbhome_1/network/admin/tnsnames.ora

SETUP =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.102.58)(PORT = 1522))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = rondg)
      (INSTANCE_NAME = sby_2)
    )
  )

This is needed since there won’t be a cross-registration of the new SCAN listener with the listener_dg:

[oracle@ron12csbynode1 ~]$ lsnrctl status listener_dg

LSNRCTL for Linux: Version 12.1.0.1.0 - Production on 28-APR-2014 04:57:13

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_DG)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER_DG
Version                   TNSLSNR for Linux: Version 12.1.0.1.0 - Production
Start Date                23-APR-2014 10:54:58
Uptime                    4 days 18 hr. 2 min. 15 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/12.1.0.1/grid/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/ron12csbynode1/listener_dg/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_DG)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.102.58)(PORT=1522)))
Services Summary...
Service "rondg" has 2 instance(s).
  Instance "sby_1", status UNKNOWN, has 1 handler(s) for this service...
  Instance "sby_2", status UNKNOWN, has 1 handler(s) for this service...
Service "rondg_DGMGRL" has 2 instance(s).
  Instance "sby_1", status UNKNOWN, has 1 handler(s) for this service...
  Instance "sby_2", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@ron12csbynode1 ~]$

If you are not using active duplication you also need to take care of the password file. After a lot of trial-and-error it became apparent that a) you can’t have the password file in ASM and b) you need to copy the original password file from the primary database. If the source password is in ASM you can use asmcmdp cp +data/RON/orapwRON.ora /tmp to copy it out of ASM. When I tried to create a password file locally I could not connect-every time I tried I had an ‘ORA-1033 “ORACLE initialization or shutdown in progress”‘ For the purpose of the duplication I am using node 1 on the standby cluster. Later on you can extend the database to both nodes.

You will need a password file to start the standby database, here is what I used:

[oracle@ron12csbynode1 dbs]$ cat initsby.ora
*.archive_lag_target=0
*.audit_file_dest='/u01/app/oracle/admin/rondg/adump'
*.audit_trail='db'
*.cluster_database=true
*.compatible='12.1.0.0.0'
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_domain=''
*.db_name='ron'
*.db_unique_name='rondg'
*.db_recovery_file_dest='+RECO'
*.db_recovery_file_dest_size=5025m
*.dg_broker_start=TRUE
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=priXDB)'
*.enable_pluggable_database=true
*.log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST','valid_for=(ALL_LOGFILES, ALL_ROLES)'
*.nls_language='ENGLISH'
*.nls_territory='UNITED KINGDOM'
*.open_cursors=300
*.pga_aggregate_target=512m
*.processes=300
*.remote_login_passwordfile='exclusive'
*.sga_target=1024m
*.standby_file_management='auto'

Since the SIDs will be sby_1 and sby_2 I created symlinks for these, pointing to the pfile. With everything in place it was time to duplicate!

[oracle@ron12cprinode1 oraback]$ rman target sys/secret@ronprinet2 auxiliary sys/secret@setup

Recovery Manager: Release 12.1.0.1.0 - Production on Mon Apr 28 05:14:35 2014

Copyright (c) 1982, 2013, Oracle and/or its affiliates.  All rights reserved.

connected to target database: RON (DBID=1681008808)
connected to auxiliary database: RON (not mounted)

RMAN> duplicate target database for standby;

...

contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=18 STAMP=846048497 file name=+DATA/RONDG/DATAFILE/system.271.846047875
datafile 3 switched to datafile copy
input datafile copy RECID=19 STAMP=846048500 file name=+DATA/RONDG/DATAFILE/sysaux.272.846047875
datafile 4 switched to datafile copy
input datafile copy RECID=20 STAMP=846048502 file name=+DATA/RONDG/DATAFILE/undotbs1.270.846047877
datafile 5 switched to datafile copy
input datafile copy RECID=21 STAMP=846048503 file name=+DATA/RONDG/F1CEE6116436678FE0433264A8C016E9/DATAFILE/system.278.846048325
datafile 6 switched to datafile copy
input datafile copy RECID=22 STAMP=846048505 file name=+DATA/RONDG/DATAFILE/users.269.846047877
datafile 7 switched to datafile copy
input datafile copy RECID=23 STAMP=846048506 file name=+DATA/RONDG/F1CEE6116436678FE0433264A8C016E9/DATAFILE/sysaux.277.846048381
datafile 8 switched to datafile copy
input datafile copy RECID=24 STAMP=846048508 file name=+DATA/RONDG/DATAFILE/undotbs2.256.846047879
datafile 9 switched to datafile copy
input datafile copy RECID=25 STAMP=846048510 file name=+DATA/RONDG/F1CF406751F56F3EE0433264A8C0E61D/DATAFILE/system.275.846048145
datafile 10 switched to datafile copy
input datafile copy RECID=26 STAMP=846048512 file name=+DATA/RONDG/F1CF406751F56F3EE0433264A8C0E61D/DATAFILE/sysaux.274.846048189
datafile 11 switched to datafile copy
input datafile copy RECID=27 STAMP=846048513 file name=+DATA/RONDG/F1CF406751F56F3EE0433264A8C0E61D/DATAFILE/users.257.846048191
datafile 12 switched to datafile copy
input datafile copy RECID=28 STAMP=846048515 file name=+DATA/RONDG/F1CF406751F56F3EE0433264A8C0E61D/DATAFILE/example.276.846048143
Finished Duplicate Db at 28-APR-14

RMAN>

After the duplication finished ensure you switch to the use of SPFILEs instead of the pfile. You also need to add the *.control_files to the (s)pfile. You could also create the spfile in ASM like I did here.

Registration with Clusterware

With the duplication complete you can register the database and a service with Clusterware:

[oracle@ron12csbynode1 ~]$ srvctl add database -d rondg -oraclehome /u01/app/oracle/product/12.1.0.1/dbhome_1 \
> -dbtype RACONENODE -server ron12csbynode1,ron12csbynode2 -instance sby -spfile '+DATA/RONDG/spfilesby.ora' \
> -role PHYSICAL_STANDBY -startoption MOUNT -diskgroup DATA,RECO

[oracle@ron12csbynode1 ~]$ srvctl add service -d rondg -s ron12c

You don’t need to start that service now, it will be started when the database is opened:

[oracle@ron12csbynode1 ~]$ crsctl stat res ora.rondg.ron12c.svc -p
NAME=ora.rondg.ron12c.svc
TYPE=ora.service.type
...
START_DEPENDENCIES=hard(ora.rondg.db,type:ora.cluster_vip_net1.type) \
weak(type:ora.listener.type) dispersion(type:ora.service.type) \
pullup(type:ora.cluster_vip_net1.type) pullup:always(ora.rondg.db)
...

Done for now

This concludes the third part of this article. We are getting closer! There is a primary and a standby database now, and all that remains to be done is the creation of the Data Guard configuration to start log shipping. You can read about that in part 4. The final part will also include demonstrations of Data Guard behaviour when you relocate the instance from node 1 to node 2. I will also show you how to perform a switchover operation.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 2,487 other followers

%d bloggers like this: