20070316 oracle instantclient and dbdoracle - plembo/onemoretech GitHub Wiki

title: Oracle Instantclient and DBD::Oracle link: https://onemoretech.wordpress.com/2007/03/16/oracle-instantclient-and-dbdoracle/ author: lembobro description: post_id: 737 created: 2007/03/16 20:43:00 created_gmt: 2007/03/16 20:43:00 comment_status: open post_name: oracle-instantclient-and-dbdoracle status: publish post_type: post

Oracle Instantclient and DBD::Oracle

_Note: I cleaned this up a bit from the original, mostly making sure that the path information was consistent.

For awhile I used to install this in /usr/lib/oracle, but that was insane. From a “where is my third-party software” perspective /opt/oracle makes so much more sense!_

This is basically a cut-and-paste from my old personal website. Had to use this today, so I thought I’d share it here. NOTE: I’m back to using the .zip files from Oracle now, after trying the rpms for a month or two. Problem is that most stuff, like PHP’s OCA module and Perl’s DBD::Oracle, don’t compile easily with the filesystem layout Oracle chose for the rpms. Just another example of how hard it is to change a “standard” once you’ve let it out into the wild.

Getting all the pieces in place to use DBD::Oracle can be a real pain. Since Oracle released it’s “Instant Client” this was supposed to have gotten easier, and over time, it has. The procedure set out here has been used to successfully compile and install DBD::Oracle on both Red Hat Enterprise 3 and 4 using Oracle Instant Client version 10.2.0.3 (which is the latest as of this writing).

This procedure uses the latest Makefile.PL (in DBD-Oracle-1.19) from the Pythian Group, who have taken over maintenance of DBD::Oracle from Tim Bunce.

To begin, download the Instant Client zip files for Linux from Oracle.

These are the files you’ll need:

`

instantclient-basic-linux32-[version].zip
instantclient-sqlplus-linux32-[version].zip
instantclient-sdk-linux32-[version].zip

`

Extract these files into /opt/oracle. This will create a subdirectory with a name like “instantclient_10_2”. The binaries and library files will be in the root, while the headers will be under instantclient_10_2/sdk/include.

On most current releases of instantclient, you’ll also need to symlink from the libclntsh.so.xx.x to libclntsh.so inside that subdirectory. I have no idea why Oracle doesn’t make this part of their zip file.

I used to provide instructions for configuring the global environment to support this. After some collisions with existing Oracle installs on various systems, I’ve come to the conclusion that it’s better to configure on a per user basis. These changes should be made at a minimum to the user who will be working with the Oracle client and especially whomever will be building DBD::Oracle.

1. Edit .bash_profile and add the following lines to it:

`

# Oracle environment
export ORACLE_HOME=/opt/oracle/instantclient_10_2
export TNS_ADMIN=$ORACLE_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME:$LD_LIBRARY_PATH

`

($TNS_ADMIN is where your tnsnames.ora and/or sqlnet.ora files would be, use a different path is they’re found somewhere else on your system)

Log out and then back in and confirm that the environment has been set correctly by doing an echo $ORACLE_HOME and echo $TNS_ADMIN.

2. Create a symlink in PATH to sqlplus, thus:
ln -s /opt/oracle/instantclient_10_2/sqlplus /usr/bin/sqlplus.

3. Test sqlplus against your favorite Oracle database. While all environments differ, make sure to follow the following syntax when invoking the utility (I use a tnsnames.ora file on my network, and these examples reflect that):

sqlplus [username]/[userpass]@[tnsentry]

To connect without a tnsnames file, do this:

sqlplus [username]/[userpass]@//[servername]:[port]/[servicename]

You should get connected. To verify you’re actually in, issue a PS SQL command, like “SHOW ALL” to see the server environment.

4. Get the DBD::Oracle tarball from CPAN

5. Unarchive the tarball

6. Execute the Makefile.PL with “perl Makefile.PL”

7. Do an “make” and “make install”

That’s it. You’re done!

Additional notes:

Since writing this I’ve successfully installed DBD::Oracle v1.21 on various platforms, but not anything later than that yet. As I’ve said in other posts, it’s crucial to use instantclient for the same architecture as the perl you’re building against. A “perl -v” will show you the arch of yours. Most systems, even 64-bit ones (e.g. Solaris), ship with 32-bit perl, as recommended by the project. The latest installs I’ve done have been with instantclient 11.1.0.7.0, and that’s worked on every platform I’ve tried so far (RHEL 4/5, Ubuntu 8.10, Solaris 8 & 10).

Copyright 2004-2019 Phil Lembo