Wednesday

What are Listener.ora , Tnsnames.ora , sqlnet.ora files?

What is a Listener.ora File?

The information about this listener can be found in the listener.ora file.
This file is normally found in the $ORACLE_HOME/network/admin folder.
If the file is not here then you can search in /etc folder if you are on a unix server.

If you have RAC then you can find the name of listener in the initdbname.ora file

So the important point you have to remember is that you should compulsorily  have a listener.ora file
if your users have to connect from a different server.

What is a Tnsnames.ora File?
The tnsnames.ora file contains the information about the server where your database is present , the
port number information , the database name , the protocol used (tcp etc ).  If a user wants to
connect to a database then the software program which the user is using will look in the
tnsnames.ora file and find out all the information what we discussed before. Then the software
program uses this information and makes a connection to the database with the help of the listener.

So important point is if a user want to connect to a database he or she would definetly need a
tnsnames.ora file.

What happens if 100 users want to connect to the database? Do we need 100 tnsnames.ora files?
If the users are using a software program that is located on their machine then each user will need his
own tnsnames.ora file. If the users are connecting to a website for example www.google.com then
the user do not need to have a tnsnames.ora on his machine because the website is located on a
webserver so the tnsnames.ora file would already be in the webserver.

Some java programs do not need a tnsnames.ora file .What they do is ,they can read all this
information from a different file which they created . The java developers speak to the dba and will
get the database information. Then they store this information in a different file. Then the java
program reads this file and will connect to the database.


What is sqlnet.ora file ?

If a tnsnames.ora file has to work properly , then we need the sqlnet.ora file. The sqlnet.ora file
contains some information which the user process(the user connection) needs ,to find exactly where
a database server is located. So the user process normally reads the tnsnames.ora file and then the
sqlnet.ora file and thus will find the complete database server information, database name etc and
will talk to the listener which is present on the database server. The listener will then will see that a
conenction is opened to the database.

There are also lot of other parameters in the sqlnet.ora file that you can use.

 For UNIX users, the order in which Oracle searches locations for Oracle Net files like sqlnet.ora and tnsnames.ora are in this order:

1. $HOME for hidden files only (i.e., .sqlnet.ora and .tnsnames.ora)
2. $TNS_ADMIN
3. $HOME
4. /etc or /var/opt/oracle (depends on platform)
5. $ORACLE_HOME/network/admin

For Windows users, the search order is a bit different. It goes like this,
1. current path (associated with the running client application)
2. Environment variable TNS_ADMIN defined for the session
3. Environment variable TNS_ADMIN defined for the system
4. Windows Registry Key TNS_ADMIN
5. %ORACLE_HOME%\network\admin

No comments:

Post a Comment