====== Installing Oracle Instant Client ======
===== Installing Oracle Instant Client on OSX =====
This document contains instructions for setting up Oracle Instant Client and connecting to an Oracle Database from Mac OSX. It shows how to install [[http://www.oracle.com/technology/tech/oci/instantclient/index.html|Oracle Instant Client Basic and SDK]], and [[http://www.oracle.com/technology/tech/sql_plus/index.html|SQL*Plus]] for and how to use SQL*Plus to connect to a remote Oracle Database.
**N.B. If you want to use the python module [[http://www.python.net/crew/atuining/cx_Oracle/|cx_Oracle]] to connect using this setup you will need to make sure you install a 10.x version of Instant Client. [[public:cxOracle|A description for setting cx_Oracle up is here]]**
- Download [[http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/intel_macsoft.html|Oracle's Instant Client Basic Package]] binary for mac (this link is an Intel build). The file should look something like ''oracle-instantclient-basic-macosx-10.2.0.4.0.zip''.
- Download [[http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/intel_macsoft.html|Oracle's Instant Client SDK Package]] binary for mac (this link is an Intel build). The file should look something like ''oracle-instantclient-sdk-macosx-10.2.0.4.0.zip''.
- Download [[http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/intel_macsoft.html|Oracle's Instant SQL*Plus Package]] binary for mac (this link is an Intel build). The file should look something like ''oracle-instantclient-sqlplus-macosx-10.2.0.4.0.zip''.
- Unzip these to some location, e.g., your Desktopcd ~/Desktop
unzip oracle-instantclient-basic-macosx-10.2.0.4.0.zip
unzip oracle-instantclient-sdk-macosx-10.2.0.4.0.zip
unzip oracle-instantclient-sqlplus-macosx-10.2.0.4.0.zip
- Enter the directory: cd instantclient10_2
- Set up symbolic links to the librariesln -s libclntsh.dylib.10.1 libclntsh.dylib
ln -s libocci.dylib.10.1 libocci.dylib
- Move the directory to somewhere more appropriate, e.g., ''/usr/local/oracle'' (the rest of these instructions assume you used this directory): sudo mkdir /usr/local/oracle
sudo mv instantclient_10_2 /usr/local/oracle/
- Set the following environment variables using commands like these. These commands should be added to your ''~/.bash_profile'' file to use this software in the future:
export ORACLE_HOME=/usr/local/oracle/instantclient_10_2
export DYLD_LIBRARY_PATH=$ORACLE_HOME
export SQLPATH=$ORACLE_HOME
export PATH=$PATH:$ORACLE_HOME
- Now load the new profile document:source ~/.bash_profile
You should now be able to run sqlplus :-)
==== Setting up tnsnames.ora ====
In order to make connecting to a database easier you can follow these instructions to store your connection settings in a ''tnsnames.ora'' file.
- Set up a new ''tnsnames.ora'' file:cd /usr/local/oracle/instantclient_10_2/
mkdir network
touch network/tnsnames.ora
- Open ''network/tnsnames.ora'' and enter the following information, replacing with your connection name, with the name of the server that is hosting the database, with the port the database connection is on, and with the service name:
=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = ))
)
(CONNECT_DATA =
(SERVICE_NAME = )
)
)
===== Installing Oracle Instant Client on Ubuntu =====
This document contains instructions for connecting to an Oracle Database from [[www.ubuntu.com/|Ubuntu]] (these instructions probably work just as well under other variants of linux). It shows how to install [[http://www.oracle.com/technology/tech/oci/instantclient/index.html|Oracle Instant Client]] and [[http://www.oracle.com/technology/tech/sql_plus/index.html|SQL*Plus]] for Ubuntu and how to use SQL*Plus to connect to a remote Oracle Database.
**N.B. If you want to use the python module [[http://www.python.net/crew/atuining/cx_Oracle/|cx_Oracle]] to connect using this setup you will need to make sure you install a 10.x version of Instant Client. [[public:cxOracle|A description for setting cx_Oracle up is here]]**
- Download the [[http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html|Oracle's Instant Client Basic Package]] rpm for linux (this should look something like ''oracle-instantclient-basic-10.2.0.3-1.i386.rpm'').
- Install the rpm using the following (where is replaced with the filename of your downloaded rpm):sudo rpm -i This should install Oracle Instant Client somewhere like ''/usr/lib/oracle/10.2.0.3/client''. Find the install location and remember it for the next step.
- Set the following environment variables using commands like these (replacing '''' with the install location you remembered from the previous step). These commands should be added to your ''.bash_profile'' file to use this software in the future:
export ORACLE_HOME=
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
- Download the optional package [[http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html|Instant Client Package - SQL*Plus]] linux rpm. (this should look something like ''oracle-instantclient-sqlplus-10.2.0.3-1.i386.rpm'')
- Install the rpm using the following (where is replaced with the filename of your downloaded rpm):sudo rpm -i This should install Oracle SQL*Plus with the Instant Client installed earlier.
- You should now be able to use SQL*Plus to connect to a remote database using the following command:
sqlplus dbusername/dbpassword@//your.domain.com:portnum/dbname
replacing ''dbusername'' with your database username, ''dbpassword'', with your database password, ''your.domain.com'' with the computer name, ''portnum'' with the port number, and ''dbname'' with the database name.
===== Troubleshooting =====
The following are some troubleshooting problems that I encountered with the fixes that sorted them out. Contact me if they don't work for you.
==== Environment Variables not set ====
If you receive the following error when running SQL*Plus:
sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory
Check your environmental variables (''ORACLE_HOME'' and ''LD_LIBRARY_PATH'') and make they are set correctly.
==== Missing ''libaio-dev'' ====
If you receive the following error when running SQL*Plus:
sqlplus: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
you are missing the required ''libaio-dev'' package. Install it using the following command:
sudo apt-get install libaio-dev