2011-11-08

Oracle Instant Client 11.2.0.3.0 in Ubuntu 11.10

As an Oracle Database Administrator, I've been involved in several projects where the installation of the Instant Client is a requirement.

I'm aware of some tutorials where people tell you to use "alien" to convert Oracle RPMs to DEBs but I preffer to use ZIPs, so I'll post here how it works including the Basic package along with the SQL*Plus and the SDK.

I'll be using the Virtual Machine created in my first post, you might want to use your own computer with Ubuntu already installed and the only difference is that you might already have the required packages installed.

Preliminaries:
  1. Get the following files from Oracle Download site:
    instantclient-basic-linux.x64-11.2.0.3.0.zip
    instantclient-sdk-linux.x64-11.2.0.3.0.zip
    instantclient-sqlplus-linux.x64-11.2.0.3.0.zip
  2. You will need unzip for the files and SQL*Plus requires the Linux kernel AIO access library, to install the packages use the following:
    sudo apt-get install unzip libaio1
Installation:
  1. Instant Client will be installed under /usr/lib/oracle, from the directory where you have the ZIP files enter the following commands:
    sudo unzip instantclient-basic-linux.x64-11.2.0.3.0.zip -d /usr/lib/oracle
    sudo unzip instantclient-sdk-linux.x64-11.2.0.3.0.zip -d /usr/lib/oracle
    sudo unzip instantclient-sqlplus-linux.x64-11.2.0.3.0.zip -d /usr/lib/oracle

  2. You need two Symbolic Links for compilation purposes, create them with the following commands:
    sudo ln -s /usr/lib/oracle/instantclient_11_2/libclntsh.so.11.1 /usr/lib/oracle/instantclient_11_2/libclntsh.so
    sudo ln -s /usr/lib/oracle/instantclient_11_2/libocci.so.11.1 /usr/lib/oracle/instantclient_11_2/libocci.so
  3. Dynamic Linker Run-Time Bindings must be configured, create a new file with the following command:
    sudo vi /etc/ld.so.conf.d/oracle.conf
    And insert the following line:
    /usr/lib/oracle/instantclient_11_2
    Save the file and run the configuration of the Dynamic Linker Run-Time Bindings with the following command:
    sudo ldconfig
  4. Some environment variables are required and you can add the directory to the path, create a new file with the following command:
    sudo vi /etc/profile.d/oracle.sh
    And insert the following lines:
    export ORACLE_HOME=/usr/lib/oracle/instantclient_11_2
    export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
    export TNS_ADMIN=/etc/oracle
    export PATH=$PATH:$ORACLE_HOME
    Please note, the NLS_LANG environment variable must match the configuration of your Oracle Database or you will have character problems I normally use one of AMERICAN_AMERICA.AL32UTF8, MEXICAN SPANISH_MEXICO.AL32UTF8, MEXICAN SPANISH_MEXICO.WE8ISO8859P1 or MEXICAN SPANISH_MEXICO.WE8ISO8859P15 but you might need another.
  5. Log out and log in again to make the new environment variables available to your user.
  6. Finally, the tnsnames.ora file must be created in the path defined in the environment variable TNS_ADMIN, create the directory with the following command:
    sudo mkdir /etc/oracle
    Create the file with the following command:
    sudo vi /etc/oracle/tnsnames.ora
    And insert the lines you need to configure your connections, for example:
    ORCL =
    (DESCRIPTION =
     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.87)(PORT = 1521))
     (CONNECT_DATA =
       (SERVICE_NAME = orcl)
     )
    )
You can now use SQL*Plus to test your installation:
sqlplus myuser@orcl

Feel free to use "alien" to make your own DEBs, I'm not against that in any way, I'm just posting this because some people I've worked with believe that just by installing those DEB files everything will work as espected ignoring some missing steps are needed. Hopefully, this will save you some time.

I hope this will help someone out there, please feel free to send any comments.

1 comment:

Anonymous said...

thanks, I'm also not a big fan of installing rpms under ubuntu