Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle - What TNS Names file am I using?

Sometimes I get Oracle connection problems because I can't figure out which tnsnames.ora file my database client is using.

What's the best way to figure this out? ++happy for various platform solutions.

like image 377
Mark Harrison Avatar asked Aug 13 '08 23:08

Mark Harrison


People also ask

What is the TNS name in Oracle?

A TNS (Transparent Network Substrate) name is the name of the entry in tnsnames.ora file which is kept in $ORACLE_HOME/network/admin. This file contains the information which is used by the system to connect to oracle database. Using this a client can fetch server associated information transparently.

Where is Tnsnames Ora file in Oracle 19c?

The tnsnames. ora file is located in both the Grid_home/network/admin and Oracle_home/network/admin directories.

Where can I find listener Ora file?

By default, the listener. ora file is located in the ORACLE_HOME/network/admin directory. The listener.

How do I list Tnsnames?

Whenever I need to find out a tnsname, I just simply search for the tnsnames. ora file with tnsping command and open it in a text editor to scan through. Then subsequently run tnsping [tnsname] to check the connection health.


2 Answers

Oracle provides a utility called tnsping:

R:\>tnsping someconnection  TNS Ping Utility for 32-bit Windows: Version 9.0.1.3.1 - Production on 27-AUG-20 08 10:38:07  Copyright (c) 1997 Oracle Corporation.  All rights reserved.  Used parameter files: C:\Oracle92\network\ADMIN\sqlnet.ora C:\Oracle92\network\ADMIN\tnsnames.ora  TNS-03505: Failed to resolve name  R:\>   R:\>tnsping entpr01  TNS Ping Utility for 32-bit Windows: Version 9.0.1.3.1 - Production on 27-AUG-20 08 10:39:22  Copyright (c) 1997 Oracle Corporation.  All rights reserved.  Used parameter files: C:\Oracle92\network\ADMIN\sqlnet.ora C:\Oracle92\network\ADMIN\tnsnames.ora  Used TNSNAMES adapter to resolve the alias Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (COMMUNITY = **)  (PROTOCOL = TCP) (Host = ****) (Port = 1521))) (CONNECT_DATA = (SID = ENTPR0 1))) OK (40 msec)  R:\> 

This should show what file you're using. The utility sits in the Oracle bin directory.

like image 74
stjohnroe Avatar answered Oct 13 '22 23:10

stjohnroe


For linux:

$ strace sqlplus -L scott/tiger@orcl 2>&1| grep -i 'open.*tnsnames.ora' 

shows something like this:

open("/opt/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora",O_RDONLY)=7 

Changing to

$ strace sqlplus -L scott/tiger@orcl 2>&1| grep -i 'tnsnames.ora' 

will show all the file paths that are failing.

like image 26
Mark Harrison Avatar answered Oct 13 '22 22:10

Mark Harrison