Wednesday, August 3, 2011

Oracle Net Service- Back to basics


Oracle Net Services:

A suite of networking components that provides enterprise-wide connectivity solutions in distributed, heterogeneous computing environments. Oracle Net Services is comprised of Oracle Net, listener, Oracle Connection Manager, Oracle Net Configuration Assistant, and Oracle Net Manager.
It enables a network session from a client application to an Oracle Database server. When a network session is established, Oracle Net acts as the data courier for both the client application and the database. It is responsible for establishing and maintaining the connection between the client application and database, as well as exchanging messages between them.

Client/Server Application Connection:



Oracle uses three files (listener.ora, tnsnames.ora & sqlnet.ora) for network configuration.

Listener.ora
Tnsnames.ora
Sqlnet.ora

Listener.ora:

The listerner.ora file contains server side network configuration parameters. It can be found in the "$ORACLE_HOME/network/admin" directory on the server. Here is an example of a listener.ora file from Windows 2000.

Tnsnames.ora:

The "tnsnames.ora" file contains client side network configuration parameters. It can be found in the "$ORACLE_HOME/network/admin" or "$ORACLE_HOME/net80/admin" directory on the client. This file will also be present on the server if client style connections are used on the server itself. Here is an example of a "tnsnames.ora" file.

Sqlnet.ora:

The "sqlnet.ora" file contains client side network configuration parameters. It can be found in the "$ORACLE_HOME/network/admin" or "$ORACLE_HOME/net80/admin" directory on the client. This file will also be present on the server if client style connections are used on the server itself. Here is an example of an "sqlnet.ora" file.

How the above files used in sequence.

The machine trying to open an Oracle connection consults thesqlnet.ora file in order to determine how the net service nameshould be resolved. This resolution is specified with the parameter names.directory_path in this very file. 

The default search order, if this parameter is not set, is: TNSNAMES, ONAMES, HOSTNAME
The net service name  is then try to locate tnsnames.ora, If no tnsnames.ora file containts the alias, the search goes on to ONAMES. Assuming there was a match in a tnsnames.ora file, thelistener end point is contacted.

Assuming there was a match in a tnsnames.ora file, the listener is contacted.
Listener tries to find the requested service. If there is no such service, a ORA-12505: TNS:listener could not resolve SID given in connect descriptor will be issued.
If everything has gone successfully, the client can now use the connection with the server process to communicate with oracle.

Enjoy:-)