Thursday, 3 September 2015

Installing Oracle instant database client in Ubuntu


In this post I am going to show how to install oracle instant client (database client) on your ubuntu machine. After this you should be able to connect to your oracle server and execute queries on it from your machine using sqlplus.


 Firstly find out whether your system is 32 bit or 64 bit. Easiest way to find out is to execute
  • uname - a
If your machine is 64 bit you should notice something like x64 in the output. If you don't see it 32 bit like in my case (refer screenshot below)

Next make sure you have alien command installed. We will need to to convert rpm packages to deb. To install simply run
  • sudo apt-get install alien 

 Installing Oracle instant database client

  1. Download instant client files from oracle site.Select correct files depending on your operating system and architecture. For me it is Ubuntu and 32 bit. So I have downloaded following files
    1. oracle-instantclient12.1-basic-
    2. oracle-instantclient12.1-sqlplus-
    3. oracle-instantclient12.1-devel-
  2. Since only rpm files are available and Ubuntu works with debian we need to convert rpm packages to deb packages.
    1. alien -k  oracle-instantclient12.1-basic-
    2. alien -k oracle-instantclient12.1-sqlplus-
    3. alien -k oracle-instantclient12.1-devel-
  3. Now to install .deb packages use dpkg -i packageName
    1. dpkg -i oracle-instantclient12.1-basic-
    2. dpkg -i oracle-instantclient12.1-sqlplus-
    3. dpkg -i oracle-instantclient12.1-devel-  
  4. Now you need to set some environment variables. Open ~/.bashrc file and add export following environment variables (add following line to file)
    1. export ORACLE_HOME=/usr/lib/oracle/12.1/client
    2. export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client/lib/
    3. export PATH=$PATH:$ORACLE_HOME/bin
  5. To make source your changes are reflected in same terminal execute
    1. source ~/.bashrc
And  you should be good to go. Verify your env variables.

Resolving errors

sometimes you may get following error

"sqlplus: error while loading shared libraries: cannot open shared object file: No such file or directory"

in this case double check you have added LD_LIBRARY_PATH environment variable and it is pointing to write directory. Quick way to check is 
  • cd <output_of_above_command>
Sqlplus should now be recognized and work as expected

If you see errors related to missing then install it using
  • sudo apt-get install libaio1

Related Links

t> UA-39527780-1 back to top