Oracle – for when it was like that when you got there

Main menu

Post navigation

Oracle Instant Client on Ubuntu…with added Aliens

“This is the voice of the Mysterons…have you got any Lemsip ?”
Yep, I’ve caught Deb’s cold and now sound like the alien menace from Captain Scarlet.
This provides a somewhat tenuous link to the subject at hand – namely installing Oracle Instant Client on Ubuntu.
I think I’d better explain. As you probably know, Ubuntu – being a Debian based Distro – uses the Debian packaging mechanism. Oracle, on the other hand, provides Instant Client for Linux in rpm ( RPM Package Manager) format. In order to bridge this divide, we’re going to need to use the alien utility. Look, I did say it was tenuous OK.

I’m doing this on a 32-bit Ubuntu installation ( 10.04, since you ask). If you’re running 64-bit, you’ll need to download the appropriate equivalent files.

We should now have the oracle software installed under /usr/lib.
Time for a quick test …

export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client/lib
sqlplus uid/pwd@server:port/tns service name

In the above example, replace server with the server the database is running on, port with the TNS port ( usually 1521 or 1526), and tns service name with the name of the tns service setup for the database on the target server. If you find all of this a bit confusing, you can skip this test bit until we’ve got the local tns lookup sorted out, in which case it all gets a lot easier.

UPDATE : A Note if you’re installing the 64-bit client

There are a couple of differences between the respective installations of the client.
First of all, the Oracle Client home directory for the 64-bit version is :

/usr/lib/oracle/11.2/client64

Secondly, the 64-bit version insists on creating a symbolic link for sqlplus as sqlplus64.
This means that you’d have to invoke sqlplus using the command sqlplus64.
To revert to using the usual command, simply edit the symbolic link as follows :

cd /usr/bin
sudo mv sqlplus64 sqlplus

Setting up the Environment Variables

At this point, I think I should point out that there’s a really helpful how to on the Ubuntu site.

For the LD_LIBRARY_PATH :

cd /etc/ld.so.conf.d
sudo gedit oracle.conf

In the file, the first line should be the path we’ve just used to set LD_LIBRARY_PATH in the test. In this case :/usr/lib/oracle/11.2/client/lib

Save the file. Now run :

sudo ldconfig

You should now have the LD_LIBRARY_PATH environment variable set each time you start a new terminal session.

Now for the other environment variables :

cd /etc/profile.d
sudo gedit oracle.sh

In this file, we’ll include the export commands for the ORACLE_HOME and TNS_ADMIN environemnt variables :

Adding TNSNAMES

In here, you need to add two files – sqlnet.ora and tnsnames.ora
This will enable you to connect to databases without having to remember ports and servers.
A typical sqlnet.ora looks something like this and works on any OS, so if you’ve got one lying around, you should be able to just copy it straight over…

Note – in this example, I’m connecting as the hr user with a password of hr to the XE database.

If all is working as it should, you should now have a SQL prompt.
Now, back to the task of plotting the downfall of Spectrum…as soon as I can find those tissues. No wonder the Mysterons were always so grumpy !