Monday, October 28, 2013

Install Oracle Instant Client in Ubuntu / Linux Mint

1. Download and install RPMs
To download related RPM select your linux version here then download following RPMs

  • oracle-instantclient*-basic-*.rpm
  • oracle-instantclient*-sqlplus-*.rpm
  • oracle-instantclient*-devel-*.rpm
2. Install alien RPM converter if you don't have

sudo apt-get install alien

3. Install RPM by converting via alen converter 

sudo alien -i oracle-instantclient*-basic-*.rpm sudo alien -i oracle-instantclient*-devel-*.rpm   sudo alien -i oracle-instantclient*-sqlplus-*.rpm
below is the terminal output 
praitheeesh@Prai-Linux ~/Downloads $ sudo alien -i oracle-instantclient12.1-basic-12.1.0.1.0-1.x86_64.rpm  dpkg --no-force-overwrite -i oracle-instantclient12.1-basic_12.1.0.1.0-2_amd64.deb Selecting previously unselected package oracle-instantclient12.1-basic. (Reading database ... 157491 files and directories currently installed.) Unpacking oracle-instantclient12.1-basic (from oracle-instantclient12.1-basic_12.1.0.1.0-2_amd64.deb) ... Setting up oracle-instantclient12.1-basic (12.1.0.1.0-2) ... Processing triggers for libc-bin ... ldconfig deferred processing now taking place praitheeesh@Prai-Linux ~/Downloads $ sudo alien -i oracle-instantclient12.1-devel-12.1.0.1.0-1.x86_64.rpm  dpkg --no-force-overwrite -i oracle-instantclient12.1-devel_12.1.0.1.0-2_amd64.deb Selecting previously unselected package oracle-instantclient12.1-devel (Reading database ... 157512 files and directories currently installed.) Unpacking oracle-instantclient12.1-devel (from oracle-instantclient12.1-devel_12.1.0.1.0-2_amd64.deb) ... Setting up oracle-instantclient12.1-devel (12.1.0.1.0-2) ... praitheeesh@Prai-Linux ~/Downloads $ sudo alien -i oracle-instantclient12.1-sqlplus-12.1.0.1.0-1.x86_64.rpm  dpkg --no-force-overwrite -i oracle-instantclient12.1-sqlplus_12.1.0.1.0-2_amd64.deb Selecting previously unselected package oracle-instantclient12.1-sqlplus. (Reading database ... 157563 files and directories currently installed.) Unpacking oracle-instantclient12.1-sqlplus (from oracle-instantclient12.1-sqlplus_12.1.0.1.0-2_amd64.deb) ... Setting up oracle-instantclient12.1-sqlplus (12.1.0.1.0-2) ...
4. Setup environment veritable

To find the installation path of sqlplus type

sudo find / -name sqlplus
praitheeesh@Prai-Linux ~ $ sudo find / -name sqlplus /usr/lib/oracle/12.1/client64/bin/sqlplus
Integrate Oracle Libraries

If oracle applications, such as sqlplus, are complaining about missing libraries, you can add the Oracle libraries to the LD_LIBRARY_PATH each time it is used, or to add it to the system library list create a new file as follows:

sudo vi /etc/ld.so.conf.d/oracle.conf
Then run ldconfig:

sudo ldconfig
   
   
why idconfig ?
ldconfig: Ldconfig is a basic system program which determines run-time linkbindings between ld.so and shared libraries. Ldconfig scans a running system and sets up the symbolic links that are used to load shared libraries properly. It also creates a cache (/etc/ld.so.cache) which speeds the loading of programs which use shared libraries.

ORACLE_HOME

set oracle path and HOME inside /etc/environment (system level , you may set in Session-wide environment level also. You need to logout and login if you set in system level more details here)

praitheeesh@Prai-Linux ~/Downloads $ cat /etc/environment  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/oracle/12.1/client64/bin/ ORACLE_HOME="/usr/lib/oracle/12.1/client64"
Type below command and make sure all the environment variables are set correctly


praitheeesh@Prai-Linux ~/Downloads $ cat /etc/ld.so.conf.d/*.conf
/usr/lib/i386-linux-gnu/mesa
# Multiarch support
/lib/i386-linux-gnu
/usr/lib/i386-linux-gnu
/lib/i686-linux-gnu
/usr/lib/i686-linux-gnu
# libc default configuration
/usr/local/lib

/usr/lib/oracle/12.1/client64/lib
# Multiarch support
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/mesa-egl
/usr/lib/x86_64-linux-gnu/mesa



praitheeesh@Prai-Linux ~/Downloads $ echo $ORACLE_HOME
/usr/lib/oracle/12.1/client64
praitheeesh@Prai-Linux ~/Downloads $


SDK fix
Some packages may look for 'oci.h' in $ORACLE_HOME/include, or in $ORACLE_HOME/rdbms/public
The instant client sometimes places the include files, such as oci.h, in /usr/include/oracle /client.
Inspect your system by running the following commands

praitheeesh@Prai-Linux /etc/profile.d $ ls $ORACLE_HOME bin  lib
If there is no 'include' directory under ORACLE_HOME, and it is located over in /usr/include/oracle/ , create a symbolic link to assist packages looking for these header files.

sudo ln -s /usr/include/oracle/12.1/client64 $ORACLE_HOME/include
praitheeesh@Prai-Linux /usr/include/oracle/12.1/client64 $ ls $ORACLE_HOME bin  include  lib
libaio1 missing

If sqlplus complains of a missing libaio.so.1 file , you will get following error

praitheeesh@Prai-Linux ~ $ sqlplus sqlplus: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
run following command to install libaio1

sudo apt-get install libaio1
5. Done, type sqlplus and connect to database

1 comment: