Pages

What is tnsnames.ora in Oracle?


Tnsnames.ora is a file which is used by oracle client to connect to oracle server.As we know when if we want to connect to oracle database from remote machine we enter into sqlplus using connect identifire as shown

C:\>sqlplus

SQL*Plus: Release 10.2.0.1 - Production on Wed Mar 21 15:28:03 2007

(c) Copyright 2000 Oracle Corporation. All rights reserved.

Enter user-name: scott/tiger@orcl

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options


This connect identifier i.e orcl in above example is resolved by sqlplus client by looking at tnsnames.ora file which is placed at the following location $ORACLE_HOME/network/admin however it can be placed at any given location and it’s path can be set in $TNS_ADMIN environment variable for unix systems.The tnsnames.ora provides the network resolution for connect identifier used by sqlplus clients and application servers.
TNSNAMES.ora contains entries as shown

TNSNAMES.ORA:
=============

V805.US.ORACLE.COM =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = DAN.US.ORACLE.COM)
(PORT = 1521)
)
(
CONNECT_DATA = (SID=ORCL))
)

LISTENER.ORA:
=============

LISTENER=
(ADDRESS_LIST=
(ADDRESS=
(PROTOCOL= TCP)
(HOST = DAN.US.ORACLE.COM)
(PORT= 1521)
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl.oracle.com)
(SID_NAME = ORCL)
)
)

As shown above the entries in TNSNAMES correspond listener entries at the server side.Address_list and Address in tnsnames.ora specifies the address of the listener which listens to incoming client requests for the given database.Also the connect_data specifies the service name i.e Sid of the databse specified at the server.

Reference: http://www.oraclefaq.net/2007/03/21/what-is-tnsnamesora/


A tnsnames.ora file maps net service names to connect descriptors. The net service name thus becomes a (most likely shorter and more readable) alias for the somewhat cumbersome net service name.

In the following example, the «text» after the equal sign is the connect descriptor while the text before the equal sign (net_service_name) is the net service name.

net_service_name=
(DESCRIPTION=
(ADDRESS=(protocol_address_information))
(CONNECT_DATA=
(SERVICE_NAME=service_name)))

For example:

ORA10 =
(DESCRIPTION = (ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = somehost)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME=ORA10)
)
)

No comments:

Post a Comment