Showing posts with label listener. Show all posts
Showing posts with label listener. Show all posts

Thursday, 30 May 2013

Creating Multiple TNS Aliases using a Response file

I often here DBAs run into TNS issues rambling on about:
“I can’t believe there was a missing bracket in the TNS entry” 
or
“The syntax was incorrect in the TNS”. 
Yes I admit, I have been one of those DBAs who has hacked away at the tnsnames.ora and has faced this issue in past. Although not widely known or used, there are solutions to this issue.

Solution A:
You can use the netca wizard, if you prefer to click away, however you need to ensure that you have X session enabled.

Solution B: (I prefer this option!)
A quicker and easy way of creating multiple entries for TNS is to use the netca response file with silent mode.

You can use the netca response file to create listener(s) as well but in this example, we will concentrate on looking at creating TNS aliases (or NET service) using a response file. This is not a new feature and has been available in previous versions of Oracle. 1. I want to create the following TNS alias (or NET service) entries for the following:

TNS Alias Net Service Protocol Hostname Port
BLUEBLUETCPlnx1211521
GREENGREENTCPlnx1221521

2. Take note of the following parameters
NSN_NUMBER – This is the number TNS alias(es) you want to create
NSN_NAMES – List all the TNS alias(es) names
NSN_SERVICE – List all the TNS service(s) associated with the TNS alias(es)
NSN_PROTOCOLS – List the protocol,host and port for each TNS alias
3. The following response file I will create is called 11203_netca.rsp and I have configured it as below:

##################### 11203_netca.rsp ######################
[GENERAL]
RESPONSEFILE_VERSION="11.2"
CREATE_TYPE="CUSTOM"
[oracle.net.ca]
INSTALL_TYPE=""custom""
NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"}
#--------------- Modify settings in this section ---------------
NSN_NUMBER=2
NSN_NAMES={"BLUE","GREEN"}
NSN_SERVICE={"BLUE","GREEN"}
NSN_PROTOCOLS={"TCP;lnx121;1521","TCP;lnx122;1521"}
#---------------------------------------------------------------
#######################################################

4. Now execute the netca utility in silent mode using the response file (eg. 11203_netca.rsp)

oracle@lnx121:[BLUE]$ netca /silent /responseFile /home/oracle/11203_netca.rsp
Output:
Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /home/oracle/11203_netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Warning: Oracle Restart is not running.
Listener configuration will not be registered/unregistered with Oracle Restart.
Default local naming configuration complete.
Created net service name: BLUE
Default local naming configuration complete.
Created net service name: GREEN
Profile configuration complete.
Oracle Net Services configuration successful. The exit code is 0
5. Verify that the TNS aliases for BLUE and GREEN is now created in tnsnames.ora:
oracle@lnx121:[BLUE]$ cat $TNS_ADMIN/tnsnames.ora
Output:
# tnsnames.ora Network Configuration File: /u01/app/oracle/11.2.0.3/db/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
 
BLUE =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = lnx121)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = BLUE)
    )
  )
 
GREEN =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = lnx122)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = GREEN)
    )
  )
6. Perform a tnsping for each TNS alias, to confirm entry is working.
a) TNS aliasBLUE 
oracle@lnx121:[BLUE]$ tnsping BLUE
Output:
TNS Ping Utility for Linux: Version 11.2.0.3.0 - Production on 29-MAY-2013 11:13:30
 
Copyright (c) 1997, 2011, Oracle. All rights reserved.
 
Used parameter files:
/u01/app/oracle/11.2.0.3/db/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL =TCP)(HOST = lnx121)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME =BLUE)))
OK (0 msec)
a) TNS aliasGREEN
oracle@lnx121:[BLUE]$ tnsping GREEN
Output:
TNS Ping Utility for Linux: Version 11.2.0.3.0 - Production on 29-MAY-2013 11:14:21
 
Copyright (c) 1997, 2011, Oracle. All rights reserved.
 
Used parameter files:
/u01/app/oracle/11.2.0.3/db/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL =TCP)(HOST = lnx122)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME =GREEN)))
OK (0 msec)
7. This now completes the TNS alias configuration.

Thursday, 9 June 2011

Viewing Realtime Alert Log via ADRCI

ADR (Automatic Diagnostic Repository) was introduced in 11g and is a datastore for diagnostic information for oracle components such as database, asm, listener and scan listeners. It stores trace files, logs in both clear text and xml format. ADR does allow the capability to see alert (and listener) logs in realtime.

For example if I wanted to view in realtime the alert log for Database called RED, I would do the following:
[oracle@lnx01] adrci
adrci> set home RED
adrci> show alert -tail -f
If you have multiple ADR homes and wish to quickly switch between alert or listener logs, I have created a script which can be downloaded called sos_alert.sh. Example of using this script are provided below, but first change to directory to where sos_alert.sh was downloaded to and set executable permission accordingly:
[oracle@lnx01] cd /home/oracle/scripts
[oracle@lnx01] chmod +x sos_alert.sh
Example 1: To view alert log for the database named RED
[oracle@lnx01] ./sos_alert.sh RED
Example 2: To view alert log for ASM
[oracle@lnx01] ./sos_alert.sh +ASM
Example 3: To view listener log for listener named “LISTENER”
[oracle@lnx01] ./sos_alert.sh LISTENER
Example 4: To view listener log for scan listener named “LISTENER_SCAN1″
[oracle@lnx01] ./sos_alert.sh LISTENER_SCAN1

Saturday, 31 July 2010

Scan Reconfiguration

As you may know, SCAN (Single Client Access Name) is a new feature that has been introduced in 11.2 Oracle RAC. To put it simply, the SCAN is actually a single name alias which can be configured for clients to connect to the cluster database. In addition it will also handle the load balancing and failover for client connections. When the nodes in the cluster changes (eg. added or removed), the benefits of SCAN can be realised, as there is no requirement for the client to be reconfigured.

A good example on configuring SCAN for clients, Pas from Oracle has written an article which explains how this can be achieved. Just visit his blog entry Using SCAN – Single Client Access Name to Connect to 11g R2 RAC from JDeveloper 11g.

Configuring your clients to used SCAN in 11.2 or later is optional, however when you install the Grid Infrastructure software for RAC, the SCAN is still required to be configured for setup of the cluster.
It is recommended that the SCAN is resolvable to 3 IP addresses. However a minimum of 1 IP Address may be configured. It should also be registered in DNS for round robin resolution.

Reconfiguration of SCAN

There may be situations where reconfiguration of the SCAN for the cluster is required.
Some examples are:
  • Allocation of IP addresses has changed for SCAN
  • Adding additional IP addresses for SCAN
  • DNS Changes associated with SCAN addressing
  • SCAN name change^
NOTE: ^ SCAN name change may be required if there is conflicting name for another cluster on same network or in DNS, however this would mean that client reference to old SCAN is required be updated. Hence caution should be taken to ensure that SCAN name is unique in DNS and network.

In the below scenario, the following steps will show how SCAN addressing can be reconfigured for a cluster.

At the time of the installation, the DNS registration had not been setup. As a workaround, one of the IP addresses allocated for the SCAN was referenced in the /etc/hosts file. Once the installation was completed and DNS registration updated, the SCAN was then reconfigured to be resolvable through DNS for all 3 IP addresses.

Below is the summary of the current and new configuration for SCAN.

CurrentNew
SCAN Namemyscanmyscan
SCAN IP Address172.43.22.89172.43.22.89
172.43.22.90
172.43.22.91
SCAN entry in /etc/hosts fileYes*No
Registered in DNS and configured for round robinNoYes

NOTE: SCAN entry in the /etc/hosts file is not recommended, hence the reconfiguration to the NEW is required.

1. Verify Current Configuration for SCAN VIP
oracle@lnx01[GRID]:/app/oracle> srvctl config scan
SCAN name: myscan, Network: 1/172.43.22.0/255.255.255.0/bge0:nxge0
SCAN VIP name: scan1, IP: /myscan.earth.com/172.43.22.89
2. Verify status of SCAN Listener:
oracle@lnx01[GRID]:/app/oracle> srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is running on node lnx02
3. Verify Current Configuration for SCAN Listener
oracle@lnx01[GRID]:/app/oracle> srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521
4. Verify Status for SCAN Listener
oracle@lnx01[GRID]:/app/oracle> srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is running on node lnx02
5. Stop the SCAN Listener
oracle@lnx01[GRID]:/app/oracle> srvctl stop scan_listener
6. Stop the SCAN VIPs
oracle@lnx01[GRID]:/app/oracle> srvctl stop scan
7. Verify Status for SCAN Listener has stopped
oracle@lnx01[GRID]:/app/oracle> srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is not running
8. Verify Status for SCAN VIP has stopped
oracle@lnx01[GRID]:/app/oracle> srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is not running
9. Update SCAN in DNS and associated IPs as required 10. Verify that resolv.conf is configured to search DNS domain that SCAN was registered for
oracle@lnx01[GRID]:/app/oracle> cat /etc/resolv.conf
search        earth.com
nameserver      172.43.7.1
nameserver      172.44.7.1
11. Verify that in DNS that that the SCAN is resolvable against all three IP Addresses
oracle@lnx01[GRID]:/app/oracle> nslookup myscan
Server:         172.43.7.1
Address:        172.43.7.1#53
Name:   myscan.earth.com
Address: 172.43.22.89
Name:   myscan.earth.com
Address: 172.43.22.90
Name:   myscan.earth.com
Address: 172.43.22.91
12. Verify that the scan IP and address name has been removed or commented out from the /etc/hosts file:
oracle@lnx01[GRID]:/app/oracle> grep myscan /etc/hosts
NOTE: In this example no rows are returned as IP and address name has been removed for scan
13. Modify the SCAN resource so that it update all SCAN VIPs resolvable by DNS
oracle@lnx01[GRID]:/app/oracle> sudo srvctl modify scan -n myscan
14. If the SCAN name was changed as well, run the following to update in Cluster Resource Control
oracle@lnx01[GRID]:/app/oracle> sudo crsctl modify type ora.scan_vip.type -attr "ATTRIBUTE=SCAN_NAME,DEFAULT_VALUE=myscan"
15. Verify that all SCAN VIPs are now resolvable and registered with the SCAN resource
oracle@lnx01[GRID]:/app/oracle> srvctl config scan
SCAN name: myscan, Network: 1/172.43.22.0/255.255.255.0/bge0:nxge0
SCAN VIP name: scan1, IP: /myscan.earth.com/172.43.22.90
SCAN VIP name: scan2, IP: /myscan.earth.com/172.43.22.91
SCAN VIP name: scan3, IP: /myscan.earth.com/172.43.22.89
16. Update the SCAN Listener with new SCAN VIPs identified from DNS
oracle@lnx01[GRID]:/app/oracle> srvctl modify scan_listener -u
17. Verify new SCAN Listeners registered for new SCAN VIPs
oracle@lnx01[GRID]:/app/oracle> srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521
SCAN Listener LISTENER_SCAN2 exists. Port: TCP:1521
SCAN Listener LISTENER_SCAN3 exists. Port: TCP:1521
18. Start SCAN Listener NOTE: This will also start the SCAN VIPs
oracle@lnx01[GRID]:/app/oracle> srvctl start scan_listener
19. Verify Status of all three SCAN VIPs have been enabled and are running.
oracle@lnx01[GRID]:/app/oracle> srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is running on node lnx02
SCAN VIP scan2 is enabled
SCAN VIP scan2 is running on node lnx01
SCAN VIP scan3 is enabled
SCAN VIP scan3 is running on node lnx01
20. Verify Status of all three SCAN Listeners have been enabled and are running.
oracle@lnx01[GRID]:/app/oracle> srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is running on node lnx02
SCAN Listener LISTENER_SCAN2 is enabled
SCAN listener LISTENER_SCAN2 is running on node lnx01
SCAN Listener LISTENER_SCAN3 is enabled
SCAN listener LISTENER_SCAN3 is running on node lnx01