Link to home
Start Free TrialLog in
Avatar of ryan_bender
ryan_bender

asked on

Trouble installing DBD::Oracle Perl module through CPAN

I'm trying to install the DBD::Oracle module for Perl.  I'm doing this through the command line on a Suse Linux box.  

First I enter: perl -MCPAN -e shell

Once the CPAN shell comes up, I enter: install DBD::Oracle

Afterwards, the installation fails.  From looking at the output I see this error repeated over and over again: DBI connect('','scott/tiger',...) failed: ORA-12162: TNS:net service name is incorrectly specified (DBD ERROR: OCIServerAttach)

I should also mention that it first looks for an Oracle client when I try to install it the first time.  I'm using the Oracle Instant Client 10.2.  Once it prompts me with the error the first time I provide a means for it to find the client.  I exit out of the CPAN shell and they enter: export LD_LIBRARY_PATH=/this/directory/instantclient_10_2.  Afterwards, it doesn't give me trouble with that and leads me to the problem at hand.

I've looked around for hours today and I still don't understand what the problem is.  I saved the entire output, so I can provide more information if needed.

Thanks.
Avatar of sentner
sentner
Flag of United States of America image

Prior to doing the install of DBD::Oracle, you need to set some environment variables.  Some of these are likely in your oracle user's .profile, so you can source that .profile first.  

Try doing something like this first:

PATH1=$PATH
LPATH=$LD_LIBRARY_PATH
. ~oracle/.profile
export TNS_ADMIN=$INSTALLPATH
export PATH=$PATH1:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LPATH
export ORACLE_USERID="user/password@MYDB"
ORACLE_SID=MYDB

Then enter the CPAN shell and try the install.  I've never done it through the CPAN shell (I usually just download and make install), nor have I used the Oracle Instant Client, but the premise is the same.  The reason it's failing is on the make test portion, because the ORACLE_USERID isn't set.  You can use tnsping to verify that you can connect to the DB prior to doing the install, to make sure you have your variables correct.
Avatar of schwertner
Look here

http://jeanchristophe.duber.free.fr/dbd_oracle_instantclient_linux/
http://www.dba-oracle.com/t_dbi_interface1.htm

Mr. Sentner is correct. In Linux you have to set environment
and kernel variables and parameters very carefully.
Avatar of ryan_bender
ryan_bender

ASKER

I played with the environmental variables a bit.  Changing the ORACLE_USERID and ORACLE_SID seemed to address the problem.  When I tried to install it again, it was using those usernames and passwords that I provided rather than the scott/tiger credentials.  But it still was failing the tests, preventing it from installing correctly.

First I ran:
          export ORACLE_USERID=username/password@THE_DB
          export ORACLE_SID=THE_DB
and saw this error repeatedly during the attempted installation:
          ORA-12154: TNS:could not resolve the connect identifier specified (DBD ERROR: OCIServerAttach)

Then I ran:
          export ORACLE_USERID=username/password
          export ORACLE_SID=THE_DB
and saw this error repeatedly during the attempted installation:
          ORA-12545: Connect failed because target host or object does not exist (DBD ERROR: OCIServerAttach)

Thinking I just needed to point where the I ran:
          export ORACLE_USERID=username/password
          export ORACLE_SID=THE_DB
          export TNS_ADMIN=/this/directory/instantclient_10_2
and saw this error repeatedly during the attempted installation:
          ORA-12545: Connect failed because target host or object does not exist (DBD ERROR: OCIServerAttach)

Then I tried:
          export ORACLE_SID=THE_DB
          export ORACLE_USERID=username/password@THE_DB
          export TNS_ADMIN=/this/directory/instantclient_10_2
and this time there wasn't any dominating problem, but there were multiple instances of these errors:
          ORA-03237: Initial Extent of specified size cannot be allocated in tablespace
          ORA-00942: table or view does not exist

So it looks like this is the right track, but not quite there yet.  Any clues?
ASKER CERTIFIED SOLUTION
Avatar of sentner
sentner
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also, add ORACLE_HOME to your list of exports, and set it to the instantclient directory.   Not sure if that's causing your problem, but it can't hurt.  TNS_ADMIN should point to whereever your tnsnames.ora file is.  

See:  http://eldapo.lembobrothers.com/2007/03/16/oracle-instantclient-and-dbdoracle/

So I went against my instincts and installed it anyway.  And it worked!  I'll remember that one for next time.  Thanks.