Advanced Configuration of TNSNames.ora

See Oracle 9i Net Services manual.pdf, 10g RAC administration
Concept
Set value of SERVICE_NAME using:
select value from v$parameter where name = 'service_names';
 
Two listener for one instance
The client try the first, if unable try the second
FAILOVER is ON by default, LOAD_BALANCE is ON by default

P1.FADALTI.COM =
(DESCRIPTION =
  (ADDRESS_LIST =
  (ADDRESS = (PROTOCOL = TCP)(HOST = lo9)(PORT = 1521))
  (ADDRESS = (PROTOCOL = TCP)(HOST = lo9)(PORT = 1522))
) (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = p1.fadalti.com)
  )
)

 

Using SOURCE_ROUTE enable Oracle Connection Manager, maybe used as above, 
in this case the first listener must be up

P1.FADALTI.COM =
(DESCRIPTION =
  (ADDRESS_LIST =
  (ADDRESS = (PROTOCOL = TCP)(HOST = lo9)(PORT = 1521))
  (ADDRESS = (PROTOCOL = TCP)(HOST = lo9)(PORT = 1522))
) (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = p1.fadalti.com)
  )
  (source_route = yes)
)

 

Try each address, in order, until one succeeds
For release 8.1 and 9i clients, FAILOVER=on
For pre-release 8.1 clients, SOURCE_ROUTE=off

Try each address, randomly, until one succeeds
Note: This option is not enabled if Use Options Compatible with Net8 8.0 Clients is selected.
LOAD_BALANCE=on
FAILOVER=on

Try one address, selected at random
Note: This option is not enabled if Use Options Compatible with Net8 8.0 Clients is selected.
LOAD_BALANCE=on

Use each address in order until destination reached
SOURCE_ROUTE=on

Use only the first address
Note: This option is not enabled if Use
Options Compatible with Net8 8.0 Clients is selected.
LOAD_BALANCE=off
FAILOVER=off
SOURCE_ROUTE=off

 

TYPE_OF_SERVICE
Specify the type of service to use for an Oracle Rdb database. 
It is used by Rdb interface tools. This feature should only be used if the application supports both Oracle Rdb and 
Oracle database services, and you want the application to load balance between the two.
    
alpha5=
 (DESCRIPTION_LIST=
  (DESCRIPTION=
    (ADDRESS=...)
    (CONNECT_DATA=
     (SERVICE_NAME=generic)
     (RDB_DATABASE=[.mf]mf_personnel.rdb)
     (GLOBAL_NAME=alpha5)))
  (DESCRIPTION=
   (ADDRESS=...)
    (CONNECT_DATA=
     (SERVICE_NAME=sales.us.acme.com))
   (TYPE_OF_SERVICE=oracle9_database))

 

TAF Transparent Application Failover

- Uncommitted transactions are rolled back
  (The application must detect the failure and reapply the DMLs up to the point of failure)
- The session is reauthorized but the state is not restored(session variables, package variables, JVM, ...)
    
No PRECONNECT
# nodel - preferred 
# node2 - preferred 
# TAF BASIC 
SERVICEl = 
  (DESCRIPTION = 
    (ADDRESS = (PROTOCOL = TCP)(HOST = nodel-vip)(PORT = 1521)) 
    (ADDRESS = (PROTOCOL = TCP)(HOST = node2-vip)(PORT = 1521)) 
    (LOADBALANCE = yes) 
    (CONNECT_DATA = 
      (SERVER = DEDICATED) 
      (SERVICE_NAME = SERVICEl) 
      #Required for TAF
      (FAILOVER_MODE = 
        #SESSION, SELECT or NONE
        (TYPE = SELECT) 
        #BASIC or PRECONNECT (if PRECONNECT than BACKUP attribute may be specified)
        (METHOD = BASIC) 
        #Retries before error
        (RETRIES = 180) 
        #Delay between retries
        (DELAY = 5) 
      ) 
    ) 
  ) 
  
PRECONNECT
# nodel - preferred 
# node2 - preferred 
# TAF BASIC 
SERVICE2 = 
  (DESCRIPTION = 
    (ADDRESS = (PROTOCOL - TCP)(HOST = nodel-vip)(PORT = 1521)) 
    (ADDRESS = (PROTOCOL = TCP)(HOST = node2-vip)(PORT = 1521)) 
    (LOADBALANCE = yes) 
    (CONNECT_DATA = 
      (SERVER = DEDICATED) 
      (SERVICE_NAME = SERVICE2) 
      #Required for TAF
      (FAILOVER_MODE = 
        #SESSION, SELECT or NONE
        (TYPE = SELECT) 
        #BASIC or PRECONNECT (if PRECONNECT than BACKUP attribute may be specified)
        (METHOD = PRECONNECT) 
        (BACKUP = SERVICE1)
        #Retries before error
        (RETRIES = 180) 
        #Delay between retries
        (DELAY = 5) 
      ) 
    ) 
  )
 
#This automatically creates a ERP and ERP_PRECONNECT service to use as BACKUP by using the -P PRECONNECT
#See 10g RAC administration
srvctl add service -d RACDB -s ERP -r RAC01 -a RAC02 -P PRECONNECT

 

PREFER_LEAST_LOADED_NODE (RAC)
If each connection is expected to be long, then distribute the workload across all available nodes by setting
PREFER_LEAST_LOADED_NODE parameter to OFF in $TNS_ADMIN/listener.ora. 
If each connection is expected to be relatively short, you can send it to the least loaded node by setting the 
PREFER_LEAST_LOADED_NODE parameter to ON, which is the default value.