Instant Client problem on RedHat with tnsnames.ora - Instant Client(Archived)

I'm having problems setting it the instant client to use tnsnames.ora on Linux.
I've copied my tnsnames.ora file from a windows system where the instant client works fine using tnsnames.ora.
On RedHat Enterprise Linux 3.0 Advanced Server (update 1), kernel 2.4.21-9.EL, I can connect to my Oracle server using the following syntax:
sqlplus login/pass#\\server/service_name
However, when I set the TNS_ADMIN environment variable to point to the directory where my tnsnames.ora file is, I always get this message:
ORA-12154: TNS:could not resolve the connect identifier specified
I don't have ORACLE_HOME set, and I don't have the full Oracle client on that machine.
I've read this forum, the FAQ, tried many things but it's still not working. Any clues? 

What connect string syntax are you using when you get
the ORA-12154? What's the entry in tnsnames.ora you
are trying to use?
Do you need to copy sqlnet.ora from Windows too?
Is TNS_ADMIN set to the directory, not including the file?
It should be set to e.g. /your/dir and not /your/dir/tnsnames.ora.
-- CJ 

I'm using:
sqlplus scott/tiger#IIOC
Where the first entry in my tnsnames.ora is:
(ADDRESS = (PROTOCOL = TCP)(HOST = <my_hostname>)(PORT = 1521))
(SERVICE_NAME = <full_service_name>)
where <my_hostname> and <full_service_name> are actual values. I've used this tnsnames.ora file on windows, both with the full Oracle client (8i) and the instant client (10g)
I did not copy sqlnet.ora from Windows. My instant client on Windows does not have a sqlnet.ora anyways.
TNS_ADMIN is set to the directory containing the tnsnames.ora (without trailing slash) and does not include the filename.
I really don't see what I'm doing wrong... 

I agree it all seems fine. So let's go back and triple check
each possible point of failure.
-- Try putting the IP address of the server in the tnsnames.ora
-- Try running SQL*Plus with the full connect syntax e.g.
sqlplus scott/tiger#"((DESCRIPTION=...)...)"
Also try this syntax on Windows.
-- Triple check the source of the tnsnames.ora - is it really
the one that is used on Windows? Check the port number etc.
-- CJ 

- Tried with the IP address same problem
- Tried with the full syntax, that works perfectly
- I triple-checked the syntax and the origin of my tnsnames.ora file, it's ok. In fact, I just used the content of that file for the full syntax invocation of sqlplus (just above)
- I used "strace" to debug and follow the system calls done by sqlplus, it is accessing my tnsnames.ora file, so it's not a problem related to accessing the file using $TNS_NAMES, but rather a problem with the content of the file. From the trace, it seemed like it was doing a lot of name resolutions (even though I was using the IP address). Maybe that could be the problem.
Can you confirm that it works on RedHat AS 3.0 update 1 (or at least something close)?

Yes, RedHat AS 3.0 is a supported Linux distribution. So that should not likely be the problem. 

Try changing the end of line terminators in the tnsnames.ora file.
-- CJ 

Have you been able to resolve this issue? 'Cause I'm facing just the same one! :(
My environment consists of:
* Debian GNU/Linux 3.1
* Oracle Instant Client (installed under /appl/database/Oracle/10g/client/Instant)
* tnsnames.ora (located under /appl/database/Oracle)
* TNS_ADMIN pointing to the directory containing tnsnames.ora mentioned above
My tnsnames.ora looks like
sid =
(HOST = host)
(PORT = port)
(SID = sid)
When doing a sqlplus usr/pwd#//host:port/sid everything works perfectly fine!
When trying to do a usr/pwd#sid I always receive:
ORA-12154: TNS:could not resolve the connect identifier specified
Using usr/pwd#"(DES...)" leads just to the same result: ERROR! :(
Btw, when omitting the password on the command line, I'm prompted by SQL*Plus to enter it, and after doing so the client hangs forever! :( 

Hello again,
I'm also using CrossOver office (wine) on the Debian box, to run some of our corporate Windows applications.
I installed Oracle Instant Client for Windows under c:\appl\database\Oracle\10g\client\Instant and tnsnames.ora under c:\appl\database\Oracle, TNS_ADMIN="c:\appl\database\Oracle".
When trying to execute "wine sqlplus usr/pwd#//host:port/sid" everything is perfectly fine, when running "wine sqlplus usr/pwd#sid" from the directory containing tnsnames.ora everything is fine as well, when executing the latter command from any other directory I always receive the ORA-12154!
I have to run the command from anywhere I like, because I have to setup an ODBC DSN within wine, in order to run some of the Windows-based applications appropriately. 

Have a look under connecting to Oracle with Instant Client maybe it helps?!
- Martin 

It worked!!!!!! The problem was really the line terminators. I guess when I FTPed the file to the Linux box, the FTP client used binary (.ora is not recognized as text).
Great advice, thanks. I should I thought about it ealier.
However, I'm a little surprised that the routine used to parse tnsnames.ora is not lenient enough to support this kind of case. I wonder if it's the same for the full client...?

I'm glad that we all resolved that problem. How is Instant Client working for you in general? 

The EOL terminator issue is the same for the full client and is
a "well known" problem that I should have remembered sooner.
-- CJ


Which tnsnames.ora will be used?

I have 2 tnsnames.ora files
- the XE server install in C:\oraclexe\app\oracle\product\11.2.0\server\network\ADMIN
- the ODT install in C:\Oracle\product\11.2.0\ODT_client1\Network\Admin
When I was stepping through the ODT 2 day tutorial, I added the ORCL entry to the one in C:\Oracle\pro....\, but was getting errors. Then I found the one in C:\OracleExe\... and that appears to be the one to use
Ok, just as I posted this, I found something interesting. When I run the SQL Developer application, it uses the one in C:\OracleExe\.... and when I try to conect via ODT/VS.NET, it tries to use the other one. If I go into the references and try to add the Oracle.DataAccess from the C:\OracleExe folder - it complains.
My questions was: when developing in VS.NET and I create a connection, how do I know which tnsNames file (when there are more than one on the local disk) will be used and when? (ANSWER) - this appears to be dictated by where I get my Oracle.DataAccess.
So if the tnsnames.ora entry in the ODT folder is not working right, but SQL Developer is, then copy the entry from the XE tnsnames.ora file to the ODT tnsnames.ora file and it appears to work.
I also found that while I can use any name for the entry in the ODT tnsnames.ora file, the SERVICE_NAME entry had to match a valid entry in the XE tnsnames.ora file. So entry that worked for me (for the ORCL example) is:
          (ADDRESS = (PROTOCOL = TCP)(HOST = = 1521))
          (CONNECT_DATA =
               (SERVER = DEDICATED)
               (SERVICE_NAME = XE)
If I made the SERVICE_NAME=ORCL, it wouldn't work. XE is the entry in the tnsnames.ora file used by XE and SQL Developer.
Edited by: justme on Apr 26, 2011 2:26 PM 
The tnsnames.ora that is used is dictated by the Oracle home the software you are using is affiliated with.
For example, if ODT is installed in /oraclehome1, then it will look in /oraclehome1/network/admin
I am by no means a SQLNet expert, but there is an environment variable called TNS_ADMIN that you can look at. This forces all apps to use the same TNSNAMES.ORA file.
Finally if you are using XE and ODT on the same machine, you probably need no alias at all if it is just a local connection. 
I checked for the TNS_ADMIN environment variable, but it doesn't exist on my machine (I tried this early from some of the other messages I saw.)
The interesting thing is that you are right, I don't even need to use the tnsnames.ora file when working with the XE locally (I wonder why that tutorial has me add the ORCL key...) Anyway, if I just use the host reference, it works just fine. Thanks for the tip.
So that leaves me thinking that I need to find another forum to post where I can find out which folder belongs to which install when using the ODBC Administrator.... Not a big deal at this time though.
Thanks again for the help.
justme wrote:
I checked for the TNS_ADMIN environment variable, but it doesn't exist on my machine (I tried this early from some of the other messages I saw.)
The interesting thing is that you are right, I don't even need to use the tnsnames.ora file when working with the XE locally (I wonder why that tutorial has me add the ORCL key...) Anyway, if I just use the host reference, it works just fine. Thanks for the tip.
So that leaves me thinking that I need to find another forum to post where I can find out which folder belongs to which install when using the ODBC Administrator.... Not a big deal at this time though.
Thanks again for the help.
JustMeTNS_ADMIN is one of the optional environment variables so it won't be set by default. If you decided to add it, you could put it in the system environment variables.
Normally it is used in deployment scenarios where the target environment already has a functioning TNSNAMES.ORA and you just want to use it. In that case you would put it in the environment of your application.

ORA-12154: TNS:could not resolve the connect identifier specified

Hi folks,
Here I installed a Oracle Client 10g (10.1 and 10.2) with administration option in my new windows installation (Windows XP Pro 64bit) without problems.
I did the configuration for TNSNAMES correctly, in sqlplus when I do connect user/pass#sid it's connect without problems. When I try to do the same thing using my program, that uses OCI to connect with database, appear the ORA-12154 error.
Where is the problem? In the other computers in our network the program runs correctly, the others are Win XP 32. Just in my computer the program don't work.
You say 10.1 and 10.2, are you talking about 2 different installations in 2 different Oracle homes? If so, probably the second client (OCI) cannot find tnsnames.ora, which is located in the other Oracle home.
You could create duplicate configuration files or, alternatively, set environment variable TNS_ADMIN to the proper $ORACLE_HOME\network\admin directory. 
No, I don't have this two installations. I tried with this two releases.... 
Your OS is Windows XP Pro 64bit, oracle software is 64bit, too? And your program is 32bit? I remember the same problem, when the change from 16bit to 32bit happened. Then, very likely, a 16bit application threw this ORA-12154 error, because the lower bit application could not found or interpret the higher version tnsnames.ora.
Do you have access to metalink? Note 114085.1 troubleshoots ORA-12154, including a section bit architecture mismatch. 
Thnaks for your reply,
The installed version of Oracle is 32bits version, and the program is 32 bits too. I already tried the 64 version of Oracle (developers release) for AMD processor but when I use it my program (32bits) can't access oci.dll (64bits), Windows don't permit 32 programs access 64 libs. I can't recompile the program for 64 bits.
Sorry, but I don't have the access to Metalink. More hints? 
Could you add following lines to your sqlnet.ora?
TRACE_DIRECTORY_CLIENT = <a_directory_you_want>
So we turn on tracing, a trace file should be created in the specified directory. If this does not happen, configuration files sqlnet.ora and tnsnames.ora are not read by the application program.
To test, if the configuration files themselves are correct, copy these into the directory, where the program executable is located. Oracle searches here first (before TNS_ADMIN,$ORACLE_HOME\network\admin) . 
I added the lines in sqlnet.ora and the trace file appear in the path that I defined. I tried to copy the config files in the same folder that the program runs but the same error appear.
Thanks again. 
Could you post both files (sqlnet and tnsnames.ora) ? 
(SERVICE_NAME = lcacore)
The tnsnames.ora file is the same for all machines, and work for sqlplus.
It looks ok and cannot be completely wrong, because it works for sqlplus. I found another hint, that invisible characters can produce this error. Characters like
CTRL-M (^M) or CTRL-R (^R) . And application B (your program) can be more sensitive than application A (sqlplus) .
To be absolutely sure, that no formal errors are in the files, recreate these files, not manually but using NetManager from the program menu.
Did you examine the trace file? It contains more detailed informations. 
Ok, I already created the conf files using NetManager. But the same problem occur.
I examined the tracefile but I didn't see any problem or wrong definition, everthing is good in trace: correct access do path's, access to tnsnames file, access for lcacore....
What flag or information can I find in the trace file that show the source of problem? 
At least the error number 12154 should be found in the trace file. Normally the lines before occurrence of the error are the most important ones. But I fear you won't find many useful informations, because the error occurs BEFORE a connection is established.
Unfortunately I don't have more ideas. Oracle support could help, but you don't have a contract. It seems the problem is related to 64bit, because this is the only difference, I can see. 
Ok, no problem. Thanks for your hints.
I didn't see problems in my trace file, the unique error that appear is:
[09-AUG-2005 11:56:43:296] Error stack follows:
NL-00427: bad list
Yes, I believe that the problem is with windows x64.
Thanks for your reply.

Instant Client on Linux Suse 9 + PHP + APache

Hello Everybody!
My task is to install Instant client on NowellSuse Linux 9 for futher connections from PHP.
For the beginning I downloaded and installed
Instalation was done using rpm -Uvh ... as in InstantClient guide was described.
Now I want to test if it was installed well.
To do this i created such env vars:
TNS file (tnsnames.ora) I created manually at dir etc/oracle/
Maybe this is the problem?
TO check instalation I run sqlplus user/pass#BASE and get errors:
1. wrong ADDRESS
2. that tns name not specified
I checked if tnsnames.ora is correct, everything was fine.
But I also noticed that in error log user was ROOT but not that I specified...
As my knowledge in Linux is very small, so I can think that I just did not do something neccesary. I read a lot of different discussions but not find reason.
Please help. Best regards.
ensure that the path for the TNS_ADMIN=/etc/oracle 
Yes, this path and env is OK. 
We've noticed that in some of our installations. If we remove all spaces from the tnsnames.ora some of the problems are solved. Specially where we've moved the tnsnames.ora from a windows box to a linux one. You could give that a go perhaps.
We also place the tnsnames.ora in $ORACLE_HOME/network/admin as this is where it is usually installed when you install the full oracle database
Message was edited by:
Carlos Perestrelo Correia 
My ORACLE_HOME is /usr/lib/oracle/
as I installed instantclient only. So should I create subdirectories /network/admin ??? and to place tnsnames.ora there? 
also change your TNS_ADMIN=$ORACLE_HOME/network/admin 
Now sqlplus works but only when I connect using
sqlplus user/pass#
If I first run sqlplus than enter user, than password (on requests) the error that service name specified wrong appears...
tnsnames.ora is like this:
path of TNS_ADMIN is set to /usr/lib/oracle/
So is this error OK when connection is done in different way, or not?
Try TNS_ADMIN=$ORACLE_HOME/network/admin, without the tnsnames.ora. Good luck! 
For OS
Set LD_LIBRARY_PATH to /usr/lib/oracle/
set TNS_ADMIN to the location of tnsnames.ora
For tnsnames.ora
(ADDRESS = (PROTOCOL = TCP)(HOST = mymachine.mydomain)(PORT = 1521))
After above setting: sqlplus scott/tiger#mydb will be available ( if scott/tiger is available )

php_oci8.dll won't load

hi all
i have problem for loading the oci8.dll extension for php 5.2.2
in my computer:
i use wamp5 version 1.6.6 (apache 2.2, php 5.2, mysql 5) on win xp sp2
i want to connect my oracle server on different computer to my webserver using instant client.
my oracle is 8.1.7, instant client 10.2.
i try the step by step guide from the underground pdf (adding the environtment value in path and tns_names), but it's not working. i also try the registry editing for those value, but it still not working...
any suggestion? 
What's the error?
Give details on the location of Instant Client and the variables you set.
Did you need to reboot after changing the environment variables?
-- cj 
Make sure your path to the php.ini file is correct. I found a bug last week that means the php.ini file isn't being loaded, therefore your extensions aren't. See my blog for more help.
Is the extension directory set in php.ini?
extension_dir = "./ext" 
there is no error shown, even though i already turn the startup error on and all error notification on in php.ini
and i have the path right, because all other extension is loaded nicely ( so the ext folder is right).
i have two webserver that i'd like to connect to oracle database, the first one, oci8.dll is loaded, i just followed the oracle guide. but has error like this:
ORA-12154: TNS:could not resolve the connect identifier specified
the other one, is not, it don't show any error notification, but in phpinfo() the extention is not loaded.
but both computer has different specs.
the first one (webserver-published):
win 2003 sp1
tns_admin refer to c:\instantclient10_2
webdev WAMP installer (apache 2.2, php 5, mysql 5)
joomla CMS 1.0.12 (i don't know if it is related)
environtment (i need to reboot fot it to take effect):
user: tns_admin and nls_lang
system: path
the second one (test server-intranet):
win xp sp2
xampp WAMP installer (apache 2.2, php 5, mysql 5)
joomla CMS 1.0.12
oracle dev 6i (8.0) form runtime and report runtime only, intsalled in c:\orant (i need it to use the oracle form/report in another computer).
tns_admin refer to c:\instantclient10_2
environtment value same as above, plus c:\orant\bin in path
and in registry there are default oracle values that was created when i installed the ora dev.
my priority is to takle the ora 12154 error because it's needed in my web report application.
please help anyone? 
The TNS error you're seeing suggests that your Oracle connection string is incorrect. What's the string you're using to connect? It should be something like:
this is my connection string:
on tnsnames.ora:
jk2 =
(Host = branchpv)
(Port = 1521)
(CONNECT_DATA = (SID = jkt2)
and in php file:
$conn = oci_connect('user, 'password', 'jk2'); 
Try this:
$conn = oci_connect('user, 'password', '//branchpv:1521/jkt2');
This bypasses the tnsnames.ora file and connects directly to your db.
thanks a lot!
this actually connected.
but i still wondering, why the tnsnames.ora is not being detected?
and i still have problem with my test server (to test the website before updated/published).
thanks all oracle for helping me solve the problem.
now i just need to learn to create online report with three output, screen, file (pdf/csv), and print. any suggestion where i start? 
One down, one to go.
I'm not sure on the reason you're not able to use the tnsnames.ora file, but I'd suggest making sure you have the correct connection string using SQL*Plus. Start at the bottom and work your way up to the top of the stack.
Can you restate all the problems you're having with your test server? Is this the one that's not loading the oci8 library?
hi sorry for long reply,
my test server actually my working pc in my office so the configuration a little bit screwed.
here are the configuration:
win xp sp2
xampp installer :apache 2 php 5 mysql 5
c:\orant --> oracle dev 6i, i install only oracle report runtime and oracle form runtime (at least that what i pick).
for the rest i have the same configuration with the web server.
what strange to me is that the error is not showing up (unlike in web server --> cannot load php_oci8.dll). so it is still a mystery for me. 
What's the problem you are trying to solve?
-- cj 
my problem is like what the title said, php_oci8.dll is not loading when start my http server.
my published web server now can connect thanks to the help of allison.
while this problem now only happen in my testing server.

Linux RPM Instant client

i've installed 2 rpms found here to connect a Oracle database we have installed.
I don't find the way to set my tnsnames, sqlplus says that he doesn't know my host.
In fact, RPM's don't give e way to put my tnsnames.ora file, no admin dir exists, and no ORACLE_HOME is given...
RPM's only install some libs and ONE bin: sqlplus...
I tried to put my tnsnames on several directories as /usr/lib/oracle... etc... and set ORACLE_HOME to this dir, but nothing is right...
Please help :) 
Read the SQL*Plus install notes (linked to from the Instant Client
page on OTN). They show how to use the new connect syntax and how
to set TNS_ADMIN if you want to use a traditional tnsnames.ora
-- CJ 
I'm in the same boat
(I need to set/find/determine $ORACLE_HOME (to compile PHP))
but I cannot find the link you describe
is this the right page:
The current Instant Client doesn't have headers, so PHP can't be compiled with it.
A lot of us are waiting for the Instant Client SDK for this very reason.
Unfortunately it is not yet available.
The main Instant Client page is:
The SQL*Plus Instant Client notes are at:
-- CJ
PS. The Instant Client does work well with pre-built PHP binaries on Windows. 
well i can throw myself in with you guys. i've pulled my hair out for the last 28 hours (and i get a lot of graft done when that happens). i see we've been waiting for this sdk for a good few months now. why so long? it is just a few library files. it should be expressely stated on the oracle website that instant client is not suiable for compilation. i'm so desperate now i would have downloaded the full client instead and saved myself a day of headaches. oh well. 
An Instant Client SDK will be released sometime after the patchset, and will be versioned
We are making sure that no more hair needlessly gets pulled out after you start using the SDK, leading to less post-pulling grafting. 
Thanks Toliver.
-- CJ 
Try putting your tnsnames.ora and sqlnet.ora in some dir and make TNS_ADMIN point to it. That should help.
Kim Nielsen
So which of the two links you provided would be the route for doing just enough install to be able build PHP w/Oracle support on Linux?
or this?
Neither document. Instant Client currently doesn't come with header files so you can't compile.
Recent posts in this and the PHP forum (PHP
speak about the availability of the Instant Client SDK which will allow compilation.
You can use Instant Client on Windows with the PHP pre-built Windows binaries.
There are various links on that will help you
find a temporary alternative.
-- CJ 
I have it all working on Solaris.
Basically, i've installed the files to:
/u01/app/oracle/Instant (SQLPlus, Instant Client
Then created a new dir
Then placed a tnsnames.ora file in there with the tns description (You can get the format from any other tnsnames.ora)
Use the env:
To compile PHP, i've installed the developer pack from Oracle10g. Once you've compiled, the installation can be deleted.
Now i just have to wait for so i can connect to a 8.1.7 database :-)
(Does anyone have a link for the patchset?) 
I tried that method and it doesn't work! I'm looking at all of the notes here and it seems as if everyone is installing from an tar file rather than an RPM. I'm confused!
I set TNS_ADMIN=/usr/lib/oracle/
In that directory I have tnsnames.ora and sqlnet.ora
I exported TNS_ADMIN
I executed sqlplus username#MYDB
I recieved
ORA-12154: TNS:could not resolve the connect identifier specified
Well. I have the same problem
I'm running Mandrake 10.0 and I have installed:
I also have export the variables
in case I missed someting I made also a link:
ln -s /mnt/win/oracle/ora81/network/admin/tnsnames.ora ~/.tnsnames.ora
in my tnsnames.ora I have something like this: =
(Host =
(Port = 1521)
then I try to connect with:
sqlplus TEST/TEST#//
sqlplus test/test#andes
sqlplus test#ANDES
sqlplus test#andes
sqlplus TEST#andes
all combinations I get
ORA-12154: TNS:could not resolve the connect identifier specified
What I missing? What's wrong? 
I found my problem....
I was using a WINDOWS (CR/LF) file format tnsnames.ora
once a copied it and converted to UNIX (LF) file format, all was working sweeet.
That should go to the manual....!!!! 
I'm glad that you found the problem. How are you using Instant Client in your environment?