There are a lot of existing tutorials for installing the oracle instant client out there, but many of them require you to go through several unnecessary steps, or are simply wrong. This leads to the misconception that installing the instant client is hard, lengthy, and generally a huge pain in the ass.
In reality, it takes about two minutes and is incredibly simple. I’ll concede that, like any piece of software, some of you will run into an edge case where my method doesn’t work. I had a fair amount of trouble getting it to work on SuSE64, but in the end it turned out to be a conflict with an existing RPM (Which no one else should really run into, since it was a proprietary RPM)
In this article I’ll be covering how to install the oracle instant client on linux (32 or 64 bit) and OS X.
So lets begin.
Step 1: The O-Files
The first thing you’ll need to do is get the zip files for the client. These can be found at http://www.oracle.com/technology/software/tech/oci/instantclient/index.html
Select the appropriate package for your target operating system. You’ll then have a choice of files to download (after agreeing to Oracle’s License Agreement).
There’s four or five packages available on this page. For our purposes, we’ll be getting the Instant Client Package – Basic and the Instant Client Package – SDK files. You may also choose to download the SQL*Plus package.
Note that you’ll need to sign up for an account in order to download these.
When you have these files downloaded, choose a location for the instantclient to live. In my case, I use /opt/local/oracle/instantclient
Copy the files you downloaded to /opt/local/oracle and unzip. This will create the directory /opt/local/oracle/instantclient_x_x (where x_x is the version number). You can keep the directory as-is, or rename to instantclient. In my example, I’ve renamed the directory.
The entire process should look like this:
matt@localmachine:/opt/local/oracle$ unzip instantclient-basic-10.2.0.4.0-macosx-x86.zip Archive: instantclient-basic-10.2.0.4.0-macosx-x86.zip inflating: instantclient_10_2/BASIC_README inflating: instantclient_10_2/classes12.jar inflating: instantclient_10_2/genezi inflating: instantclient_10_2/libclntsh.dylib.10.1 inflating: instantclient_10_2/libnnz10.dylib inflating: instantclient_10_2/libocci.dylib.10.1 inflating: instantclient_10_2/libociei.dylib inflating: instantclient_10_2/ojdbc14.jar inflating: instantclient_10_2/libocijdbc10.dylib inflating: instantclient_10_2/libocijdbc10.jnilib matt@localmachine:/opt/local/oracle$ unzip instantclient-sdk-10.2.0.4.0-macosx-x86.zip Archive: instantclient-sdk-10.2.0.4.0-macosx-x86.zip creating: instantclient_10_2/sdk/ creating: instantclient_10_2/sdk/demo/ inflating: instantclient_10_2/sdk/demo/cdemo81.c inflating: instantclient_10_2/sdk/demo/demo.mk inflating: instantclient_10_2/sdk/demo/occidemo.sql inflating: instantclient_10_2/sdk/demo/occidemod.sql inflating: instantclient_10_2/sdk/demo/occidml.cpp inflating: instantclient_10_2/sdk/demo/occiobj.cpp inflating: instantclient_10_2/sdk/demo/occiobj.typ creating: instantclient_10_2/sdk/include/ inflating: instantclient_10_2/sdk/include/nzerror.h inflating: instantclient_10_2/sdk/include/nzt.h inflating: instantclient_10_2/sdk/include/occi.h inflating: instantclient_10_2/sdk/include/occiAQ.h inflating: instantclient_10_2/sdk/include/occiCommon.h inflating: instantclient_10_2/sdk/include/occiControl.h inflating: instantclient_10_2/sdk/include/occiData.h inflating: instantclient_10_2/sdk/include/occiObjects.h inflating: instantclient_10_2/sdk/include/oci.h inflating: instantclient_10_2/sdk/include/oci1.h inflating: instantclient_10_2/sdk/include/oci8dp.h inflating: instantclient_10_2/sdk/include/ociap.h inflating: instantclient_10_2/sdk/include/ociapr.h inflating: instantclient_10_2/sdk/include/ocidef.h inflating: instantclient_10_2/sdk/include/ocidem.h inflating: instantclient_10_2/sdk/include/ocidfn.h inflating: instantclient_10_2/sdk/include/ociextp.h inflating: instantclient_10_2/sdk/include/ocikpr.h inflating: instantclient_10_2/sdk/include/ocixmldb.h inflating: instantclient_10_2/sdk/include/odci.h inflating: instantclient_10_2/sdk/include/oratypes.h inflating: instantclient_10_2/sdk/include/ori.h inflating: instantclient_10_2/sdk/include/orid.h inflating: instantclient_10_2/sdk/include/orl.h inflating: instantclient_10_2/sdk/include/oro.h inflating: instantclient_10_2/sdk/include/ort.h inflating: instantclient_10_2/sdk/include/xa.h inflating: instantclient_10_2/sdk/ott extracting: instantclient_10_2/sdk/ottclasses.zip inflating: instantclient_10_2/sdk/SDK_README matt@localmachine:/opt/local/oracle$ mv instantclient_10_2 instantclient
Step 2: The missing link
Now that the files have been unzipped, there’s a key step here that most people over look. By default, the files included in the package are named with their version number prepended to the library file. This means that any piece of software looking for it won’t find it, because the filename has something like .10.1 after it.
The files you’ll need to symlink differ on Linux and OS X. In particular, on linux, the files are .so, whereas on OS X, the files are .dylib
The two files that need to be symlinked are libocci, and libclntsh.
On OS X:
matt@localmachine:/opt/local/oracle/instantclient$ ln -s libocci.dylib.10.1 libocci.dylib matt@localmachine:/opt/local/oracle/instantclient$ ln -s libclntsh.dylib.10.1 libclntsh.dylib
On Linux:
matt@localmachine:/opt/local/oracle/instantclient$ ln -s libocci.so.10.1 libocci.so matt@localmachine:/opt/local/oracle/instantclient$ ln -s libclntsh.so.10.1 libclntsh.so
This is one of the most important parts of the installation, so it’s important not to forget it.
Step 3: There’s no place like $ORACLE_HOME
Now that you have your files in the correct location, you need to set a few environment variables. The first two are the same across all platforms, but the third differs depending on whether or not you’re using Linux or OS X.
On OS X:
matt@localmachine:/opt/local/oracle$ export ORACLE_HOME=/opt/local/oracle/instantclient matt@localmachine:/opt/local/oracle$ export TNS_ADMIN=$ORACLE_HOME matt@localmachine:/opt/local/oracle$ export DYLD_LIBRARY_PATH=$ORACLE_HOME
On Linux:
matt@localmachine:/opt/local/oracle$ export ORACLE_HOME=/opt/local/oracle/instantclient matt@localmachine:/opt/local/oracle$ export TNS_ADMIN=$ORACLE_HOME matt@localmachine:/opt/local/oracle$ export LD_LIBRARY_PATH
Additionally, it would be wise to place these variables in a script that will be run when a user logs in. I generally keep these in /etc/profile (assuming your using a bash shell). ~/.bashrc or ~/.profile are two other good locations, but those are on a per user basis. Anything and everything that will use the instantclient needs these variables set (that includes the user who runs apache)
Step 4: TNSNames.ora (Not very clever, is it?)
Next you’ll need to set up your tnsnames.ora file. If you don’t know what this is, check with your DBA. If you don’t have a DBA and you’re not sure what it is, you probably won’t be using it, and you can skip this step.
Place your tnsnames.ora file in the location that you installed the instantclient. This should be the same as the path that $TNS_ADMIN points to. I have noticed that certain applications (like SQLDeveloper) seem to disregard the $TNS_ADMIN variable (or it simply doesn’t see it) and looks for the file in your home directory. For that case, you can provide a symlink to the file in ~
matt@localmachine:/opt/local/oracle/instantclient$ ln -s tnsnames.ora ~/tnsnames.ora
Thanks for the info