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.
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.
There is another place where the TNS location is stored: If you're using Windows, open
regedit
and navigate toMy HKEY Local Machine/Software/ORACLE/KEY_OraClient10_home1
whereKEY_OraClient10_home1
is your Oracle home. If there is a string entry calledTNS_ADMIN
, then the value of that entry will point to the TNS file that Oracle is using on your computer.The easiest way is probably to check the PATH environment variable of the process that is connecting to the database. Most likely the tnsnames.ora file is in first Oracle bin directory in path..\network\admin. TNS_ADMIN environment variable or value in registry (for the current Oracle home) may override this.
Using filemon like suggested by others will also do the trick.
Shouldn't it always be "$ORACLE_ HOME/network/admin/tnsnames.ora"? Then you can just do "echo $oracle_ home" or the *nix equivalent.
@Pete Holberton You are entirely correct. Which reminds me, there's another monkey wrench in the works called TWO_ TASK
According http://www.orafaq.com/wiki/TNS_ADMIN
TNS_ADMIN is an environment variable that points to the directory where the SQL*Net configuration files (like sqlnet.ora and tnsnames.ora) are located.
Codeslave asks "Shouldn't it always be "$ORACLE_ HOME/network/admin/tnsnames.ora"? The answer is no, it isn't. Consider these two invocations of tnsping on the same machine:
Note the two different parameter file locations, that are dependent on which tnsping executable you're running (and perhaps where it's being run from). For tnsnames-based oracle networking, using the TNS_ADMIN variable is the only way to ensure you're getting a consistent tnsnames.ora file. (NOTE: Windows-centric answer)
On my development machine I have three different versions of Oracle client software. I manage the
tnsnames.ora
file in one of them. In the other two, I have entered in thetnsnames.ora
file:This way, if for some reason the wrong
tnsnames.ora
file is used by a client, it will always end up at the up-to-date version.Not direct answer to your question, but I've been quite frustrated myself trying find and update all of the tnsnames files, as I had several oracle installs: Client, BI tools, OWB, etc, each of which had its own oracle home. I ended up creating a utility called TNSNamesSync that will update all of the tnsnames in all of the oracle homes. It's under the MIT license, free to use here https://github.com/artybug/TNSNamesSync/releases
The docs are here: https://github.com/artchik/TNSNamesSync/blob/master/README.md
This is for Windows only, though.