Thursday 8 June 2017

Install SQLPLUS on Debian based systems


Install SQLPLUS on Debian based systems



SQLPLUS install on Debian


I have  often had to install the sqlplus instant client on debian based systems. Below I am sharing how I last went about this on Ubuntu 13.04 but the guide should be solid on other debian based distros.
SQLPLUS install Ubuntu 13.04 64 Bit

First download the package alien from the ubuntu repos. This will allow you to install rpm packages on debian based systems.
sudo apt-get install alien

Next head on over to the Oracle site and download the instant client packages listed below, you can download then all if you want but these 3 will give you the basics.
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
Once that is done, go to your download folder and execute the following:

sudo alien -i oracle-instantclient12.1-basic*.rpm
sudo alien -i oracle-instantclient12.1-sqlplus*.rpm
sudo alien -i oracle-instantclient12.1-devel*.rpm
sudo apt-get install libaio1
sudo touch /etc/ld.so.conf.d/oracle.conf
sudo ldconfig


Now make sure everything is working by trying to establish an sqlplus session by building the TNS entry as below.
Notice that the command for using sqlplus is sqlplus64 as this is a 64bit install. You can of course alias this if you wish but out of the box it will work as below.

sqlplus64 username/password@//dbhost:1521/SID


Thats it, you should be done.
But that's never the case is it  :)

You will now find that you get the error

sqlplus64: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory


This is due to you having to set the LD_LIBRARY path variable to point at the required lib folder below.

/usr/lib/oracle/12.1/client64/lib/libsqlplus.so

To fix this issue add these system variables with the following commands:

touch ~/.bash_profile
echo export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib/ >> ~/.bash_profile
. ~/.bash_profile


Now when you run sqlplus64 you should be good to go.
If you want to create a tnsnames.ora that oracle will use to store TNS entries then create your tnsnames.ora file where you want it and reference it as an environment variable by adding the following to the ~/.profile file with the following commands.

echo export TNS_ADMIN=~/yourPathToFolderContainingTnsnames.ora >> ~/.bash_profile
. ~/.bash_profilevel*.rpm
sudo apt-get install libaio1
sudo touch /etc/ld.so.conf.d/oracle.conf
sudo ldconfig
touch ~/.bash_profile
echo export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib/ >> ~/.bash_profile
. ~/.bash_profile

No comments:

Post a Comment