Background
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.
Prerequisites
Firstly find out whether your system is 32 bit or 64 bit. Easiest way to find out is to execute
- uname - a
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
- 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
- oracle-instantclient12.1-basic-12.1.0.2.0-1.i386.rpm
- oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.i386.rpm
- oracle-instantclient12.1-devel-12.1.0.2.0-1.i386.rpm
- Since only rpm files are available and Ubuntu works with debian we need to convert rpm packages to deb packages.
- alien -k oracle-instantclient12.1-basic-12.1.0.2.0-1.i386.rpm
- alien -k oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.i386.rpm
- alien -k oracle-instantclient12.1-devel-12.1.0.2.0-1.i386.rpm
- Now to install .deb packages use dpkg -i packageName
- dpkg -i oracle-instantclient12.1-basic-12.1.0.2.0-1.i386
- dpkg -i oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.i386.rpm
- dpkg -i oracle-instantclient12.1-devel-12.1.0.2.0-1.i386.rpm
- Now you need to set some environment variables. Open ~/.bashrc file and add export following environment variables (add following line to file)
- export ORACLE_HOME=/usr/lib/oracle/12.1/client
- export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client/lib/
- export PATH=$PATH:$ORACLE_HOME/bin
- To make source your changes are reflected in same terminal execute
- source ~/.bashrc
Resolving errors
sometimes you may get following error
"sqlplus: error while loading shared libraries: libsqlplus.so: 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
- echo $LD_LIBRARY_PATH
- cd <output_of_above_command>
If you see errors related to libaio.so.1 missing then install it using
- sudo apt-get install libaio1
Related Links
- Oracle Instant Client
- Oracle Sqlplus client on Mac
- sqlplus remote connection giving ORA-21561: OID generation failed
- Install Oracle instant client and sqlplus using Homebrew(OSFG)
No comments:
Post a Comment