Tuesday, May 27, 2008

Oracle client-only on unix systems

I've seen DBAs grab & run the full Oracle installer on *nix systems just to get the client components. This is unecessary.

Go to the Oracle download site for the client components coresponding to the database verison you want to access. Install basic libs, sdk (probably optional) & sqlplus off the web.

* say you have installed all this in /opt/instantclient
then:
* set an ORACLE_HOME environment variable to /opt/instantclient
* add ORACLE_HOME to your PATH
* add ORACLE_HOME to your LD_LIBRARY_PATH
* set ORACLE_SID to the name of the database you usually want to connect to...

add a .tnsnames.ora file to your home dotfiles (I still do not know how to specify a default system-wide tnsnames file on unix).

Now, when you (or a script running in your environment) execute SQLPLus, it can find it's libraries etc. Likewise things such as DBD::Oracle will also work.

You CAN also dispense with a tnsnames file completely for SQLPLus - specifying host, port & datasource explicitly but this is a very long command line & requires escaping brackets etc.

EDIT (Jan 2010) - there are some systems where you will NEVER be able to get sqlplus to work - even if you follow the installation instructions. I suspect that there are just broken library paths compiled into the oracle binary. The attitude on the forums is the same as you will meet when dealing with most oracle admins: it's your fault, check everything that you've already checked etc. it's a problem with your OS, blah.

Such is the lot of the middleware guy. I'm just glad I won't have to do this shit for much longer...

No comments: