Installing and Configuring Oracle Instant Client 10.2.0.4 on Ubuntu 9.10

Lets be blunt about it. The Oracle client can be a real pain to get working sometimes. Following are some basic steps that I used to get a properly working Oracle client installation on Ubuntu 9.10.

Helpful Links


http://download.oracle.com/docs/cd/B12037_01/java.101/b10979/instclient.htm#sthref1813

Getting the files


The Oracle Instant Client main page is here. You will need to register (free account) with Oracle to access their free downloads. After you’ve registered, you can grab the following files from Oracle (10.2.0.4 is the current version as of the writing of this article). You may not need all of these, but I wanted to make sure that I had a complete installation of the client software.
oracle-instantclient-basic-10.2.0.4-1.i386.rpm
oracle-instantclient-sqlplus-10.2.0.4-1.i386.rpm
oracle-instantclient-devel-10.2.0.4-1.i386.rpm
oracle-instantclient-jdbc-10.2.0.4-1.i386.rpm
oracle-instantclient-odbc-10.2.0.4-1.i386.rpm

Lets debianize the rpm’s

$ apt-get install alien rpm
$ sudo alien oracle-instantclient-basic-10.2.0.4-1.i386.rpm
$ sudo alien oracle-instantclient-devel-10.2.0.4-1.i386.rpm
$ sudo alien oracle-instantclient-sqlplus-10.2.0.4-1.i386.rpm
$ sudo alien oracle-instantclient-jdbc-10.2.0.4-1.i386.rpm
$ sudo alien oracle-instantclient-odbc-10.2.0.4-1.i386.rpm

Unfortunately the oracle-instantclient-basic rpm has a deprecated libstdc++.so.5 dependency, see this link for an excellent explanation of the issue and a solution.

To fix this issue, we need to additionally download the following file (32bit version, other versions are listed here):
http://www.oracle.com/technology/tech/oci/occi/downloads/occi_gcc343_102030.tar.gz

Repackaging the Instant Client Basic package


NOTE: if you are in a hurry, you can skip all of these repackaging steps and just install the deb’s as-is. Once they are installed, then copy the contents of the occi_gcc343_102030.tar.gz file to the $ORACLE_HOME/client/lib directory

Unpack the oracle-instantclient-basic package to a temporary directory to correct the libocci dependency

Extract the package data files

$ dpkg-deb -x oracle-instantclient-basic_10.2.0.4-2_i386.deb \
    tmp/oracle-instantclient-basic_10.2.0.4-2_i386

Extract the package control files

$ dpkg-deb -e oracle-instantclient-basic_10.2.0.4-2_i386.deb \
    tmp/oracle-instantclient-basic_10.2.0.4-2_i386/DEBIAN

Extract the new OCCI library and overwrite the deprecated files extracted from the package

$ tar -zxvf occi_gcc343_102030.tar.gz
$ mv libocci.so.10.1 libocci10.a \
    tmp/oracle-instantclient-basic_10.2.0.4-2_i386/usr/lib/oracle/10.2.0.4/client/lib/

Update the debian control files (Only really need to change the md5sums file)

$ cd tmp/oracle-instantclient-basic_10.2.0.4-2_i386
$ find usr/ -type f | xargs md5sum > DEBIAN/md5sums

Remove the old package in main directory, change ownership of package files to root and rebuild the debian package file

$ rm oracle-instantclient-basic_10.2.0.4-2_i386.deb
$ sudo chown -R root:root tmp/oracle-instantclient-basic_10.2.0.4-2_i386
$ dpkg-deb -b tmp/oracle-instantclient-basic_10.2.0.4-2_i386/ \
    oracle-instantclient-basic_10.2.0.4-2_i386.deb

Installing and Configuring

Now we can finally install the packages!

$ sudo dpkg -i oracle-instantclient-*

At this point you’ll probably want to set up some additional configuration details.

  • Set ORACLE_HOME in your .bashrc, or on the command line, following are all the variables I set
    export ORACLE_HOME=/usr/lib/oracle/10.2.0.4/client
    export PATH=$PATH:$ORACLE_HOME/bin
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
    export TNS_ADMIN=$ORACLE_HOME/network/admin
    
  • If you have a tnsnames.ora file (make sure the filename is all lowercase), you can install it as well
    $ sudo mkdir -p $ORACLE_HOME/network/admin
    $ sudo cp tnsnames.ora $ORACLE_HOME/network/admin
    

You can now test your Oracle client installation by connecting to a database with sqlplus (By the way, putting the password in the command line is not recommended as it can easily be pulled out of your history file by other nosy users if your permissions are too lax).

$ sqlplus 'username/password@SID'

If for some reason you have some trouble connecting, you can create a sqlnet.ora file under $ORACLE_HOME with some tracing options.

$ sudo vi $ORACLE_HOME/network/admin/sqlnet.ora

TRACE_DIRECTORY_CLIENT=/tmp
TRACE_LEVEL_CLIENT=SUPPORT

The next time the Oracle Instant Client is used, it will create a detailed log file under /tmp like the following: cli_1968.trc. Make sure to turn this option off when you are done as the logfile can get quite large!

That’s about it, any questions or suggestions, please post them!

Leave a Reply