Wednesday, April 25, 2012

Setting up 10g Database with 11g SCAN

What is SCAN?
SCAN is Single Client Access Name with which you do not have to worry about sending out all your RAC Node information to your developers to add them into their TNS Entries... With SCAN, you just need the SCAN Address that goes in their TNS which internally maps to all your RAC Nodes. Read more in Oracle DOCS.

This cool feature is available only in 11g and not in 10g. If you are reading this then I would assume you have 10g database running in 11g RAC and you would like to make use of this SCAN Feature for 10g databases.

Here are the simple steps to integrate 10g Databases with 11g SCAN.
What you need is SCAN IP Addresses (remember just the host name is not enough for 10g).
Find the IP Addresses defined for SCAN by doing nslookup on the SCAN Host Name:

oragrid@racnode1 $ nslookup orascan.at.your.company.com 
Server: 10.1.10.111
Address: 10.1.120.111#53

Name: orascan.at.your.company.com
Address: 10.1.120.201
Name: orascan.at.your.company.com 
Address: 10.1.120.202
Name: orascan.at.your.company.com 
Address: 10.1.120.203


What you need is the above three IP addresses (might be more or less depending on your SCAN setup).

Step#1:
There should be a CRS service configured  in the OCR for clients to connect to this database.
Run the following and see if its registered and running fine:

$ srvctl status service -d DB10G 
Service DB10G_SCAN is running on instance(s) DB10G1, DB10G2

If you see the above results for your database then you are ready for Step#2. If not then do the following to add:

$ srvctl add service -d DB10G -s DB10G_SCAN -r DB10G1,DB10G2 --This will add the service
$ srvctl start service -d DB10G -s DB10G_SCAN --This will start the service. Once this is done run the above to check the status.


Step#2:
Add Local and Remote Listener entries in TNSNAMES.ora on each node where this database instance is running. Oh which Oracle Home TNSNAMES? I have 11g and 10g???. Add it in 10g Home TNSNAMES.ora as this is the entry that is used for 10g databases.

LISTENER_DB10G1 =
  (ADDRESS = (PROTOCOL = TCP)(HOST = racnode1-vip.your.domain.com)(PORT = 1521))

LISTENER_DB10G2 =
   (ADDRESS = (PROTOCOL = TCP)(HOST = racnode2-vip.your.domain.com)(PORT = 1521))

LISTENERS_GRID =
   (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.120.201)(PORT = 1521))
     (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.120.202 )(PORT = 1521))
     (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.120.203 )(PORT = 1521))
   )
Note: please make sure to double check the entries in TNSNAMES.ORA thoroughly as any typos (and syntax with parenthesis) from the TNS and below parameter settings will gives you more trouble.

Step#3:
Now login into database instance(s) and add LOCAL_LISTENER and REMOTE_LISTENER parameters to spfile:

alter system set local_listener='LISTENER_DB10G1' scope=spfile sid='DB10G1'; -- on Node1
alter system set local_listener='LISTENER_DB10G2' scope=spfile sid='DB10G2'; -- on Node2
alter system set remote_listener='LISTENERS_GRID' scope=spfile sid='*'; --on Both Nodes

Step#4:
Since we only used scope=spfile in the above, we need to bounce the database to take those parameters effective. So, go ahead and bounce the database using either srvctl stop database or individually in each node.

Step#5:
Check the listener status (lsnrctl stat) and you should be seeing this new DB10G_SCAN (the name used in Step#1) entry with the instances.

Service "db10g_scan" has 1 instance(s).
  Instance "db10g1", status READY, has 1 handler(s) for this service...
Above is from the node1

You can also check the GRID Listener status for the scan from the GRID Home:

grid@racnode1 $ lsnrctl service LISTENER_SCAN1

Service "db10g_scan" has 2 instance(s).
  Instance "db10g1", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST= racnode1-vip.your.domain.com )(PORT=1521))
  Instance "db10g2", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST= racnode2-vip.your.domain.com )(PORT=1521))
The command completed successfully


Step#6:
Now, all server side setup is ready, move on the client side.
Here is the TNS Entry that will be used at the clients PC:

DB10G_SCAN =
  (DESCRIPTION =
     (ADDRESS_LIST =
       (ADDRESS = (PROTOCOL = TCP)(HOST =  10.1.120.201 )(PORT = 1521))
       (ADDRESS = (PROTOCOL = TCP)(HOST =  10.1.120.202 )(PORT = 1521))
       (ADDRESS = (PROTOCOL = TCP)(HOST =  10.1.120.203 )(PORT = 1521))
    ) 
    (LOAD_BALANCE = yes)
    (CONNECT_DATA = 
      (SERVER = DEDICATED)
      (SERVICE_NAME = DB10G_SCAN) #This is the name that you defined in Step#1
    )
  )

As you see, the actual RAC VIP nodes are not used in the HOST but the SCAN IP Addresses.

Hope this notes helped you...

Sunday, April 22, 2012

DBCA would not offer to create RAC Database...

Environment:
11gR2 RAC with ASM
10G software installed to accommodate 10g Databases along with 11g in the ASM.


Once installed 10g and applied patch 10.2.0.5.6, DBCA will not offer to create a database which is RAC enabled. Basically it still thinks that 10g software is standalone to that local node.



OLSNODES shows all 4 nodes active but they are Un-Pinned:

+ASM1:11.2.0:/opt/oradev> olsnodes -t
ndhdbd1 Unpinned
ndhdbd2 Unpinned
ndhdbd3 Unpinned

Try pinning them as root:

#>/u01/app/11.2.0/grid/bin/crsctl pin css -n node1

Run the above for all other nodes.

+ASM1:11.2.0:/opt/oradev> olsnodes -t
ndhdbd1 Pinned
ndhdbd2 Pinned
ndhdbd3 Pinned

Now try DBCA and it will offer to create a database which is RAC Enabled.