Net Service Names and the tnsnames.ora File
The Oracle RAC database installation process creates a
tnsnames.ora file on each node. This file acts as a repository of net
service names.
Each net service name is associated with a connect identifier. A connect identifier is an identifier that maps a user-defined name to a connect descriptor. A connect descriptor contains the following information:
-
The network route to the service, including the location of the listener through a protocol address
-
The
SERVICE_NAMEparameter, with the value set to the name of a database serviceNote:
TheSERVICE_NAMEparameter that you use in thetnsnames.orafile is singular, because you can specify only one service name.
Typically, tools such as Oracle DBCA and Oracle Net Configuration Assistant (NETCA)
create the tnsnames.ora file in the ORACLE_HOME/network/admin directory for Oracle AI Database
installations, the GRID_HOME/network/admin directory for Oracle Grid Infrastructure
installations, or the corresponding ORACLE_BASE_HOME/network/admin directory for a read-only
Oracle home. Note that if you have installed multiple databases, then the file is
created in the Oracle home or Grid home where DBCA or NETCA is run (or the Oracle base
home for read-only instances).
Oracle Net checks for the tnsnames.ora file in the following order:
-
The directory specified by the
TNS_ADMINenvironment variable. -
If the
TNS_ADMINenvironment variable is not set or the file is not found in theTNS_ADMINdirectory:-
For Oracle AI Database installations:
The
ORACLE_HOME/network/admindirectory (or itsORACLE_BASE_HOME/network/admindirectory for a read-only Oracle home). -
For Oracle Grid Infrastructure installations:
The
GRID_HOME/network/admindirectory (or itsORACLE_BASE_HOME/network/admindirectory for a read-only Oracle home).
-
-
For a read-only Oracle home, if the file is not found in the Oracle base home:
-
For Oracle AI Database installations:
The
ORACLE_HOME/network/admindirectory. -
For Grid Infrastructure installations:
The
GRID_HOME/network/admindirectory.
-
The listener associations are configured as follows:
-
DBCA no longer sets the
LOCAL_LISTENERparameter. The Oracle Clusterware agent that starts the database sets theLOCAL_LISTENERparameter dynamically, and it sets it to the actual value, not an alias. Solistener_aliasentries are no longer needed in thetnsnames.orafile. -
The
REMOTE_LISTENERparameter is configured by DBCA to reference the SCAN and SCAN port, without any need for atnsnames.oraentry. Oracle Clusterware uses the Easy Connect naming method withscanname:scanport, so no listener associations for theREMOTE_LISTENERparameter are needed in thetnsnames.orafile.
For example, after you create the database, to add a second listener, listening on port 2012, use a command similar to the following command to have the database register with both listeners on startup:
SQL> alter system set local_listener='(DESCRIPTION=
(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.61)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.61)(PORT=2012))))'
scope=BOTH SID='OCRL1';