This is a situation that I have faced more than once: new computer, new OS install, new job, or just something that broke and I needed to start over.
It happened again around september last year, when I joined ThoughtWorks: I had to compile TOra from sources to get Oracle support in it. I am a Debian user, so the TOra that can be installed from the repositories does not offer native support for Oracle for licensing (and freedom) reasons. The same feature is present in the package distributed by Ubuntu.
If you are also trying to get Oracle support in TOra, bear with me. But before I get to the actual compilation walkthrough, note that I am running Debian squeeze 64-bit, so you may need to adapt some paths if you’re running 32-bit.
Also, whenever I post commands to be issued, pay attention to the prompt character. If it’s a dollar sign ($), the command can be run as a normal user; if it’s a pound sign (#), then that command must be run as root.
Ready? Let’s get our hands dirty, then.
1. Getting and installing the Oracle software
The first step is to actually get a basic Oracle client and sdk installed. Head over to the Instant Client download page (64-bit|32-bit). You might need to create a user before downloading anything from there.
To me, the easiest way to get these installed is to download the RPMs and converting them with alien. The packages you’ll need are:
- Instant Client Package – Basic or Basic Lite (This is the client that will handle the connections to the server. The difference between the versions is that the Basic Lite one is only in English and its filesize is smaller);
- Instant Client Package – SQL*Plus (Excellent for testing the installation and running PL/SQL scripts from the CLI);
- Instant Client Package – SDK (Needed for compiling TOra).
Once you have downloaded the packages, head to the directory where you saved them and execute the following line of code (you need to have fakeroot, alien and rpm installed beforehand):
$ for n in $(ls oracle-*.rpm); do fakeroot alien $n; done;
Then, as root (or using sudo):
# dpkg -i *.deb
The installation will be split into two separate trees: one for the binary blobs, and one for the SDK. The binaries are placed under /usr/lib/oracle/<version>/client, while the SDK is under /usr/include/oracle/<version>/client. I am using Oracle version 11.2 64-bit, so my dirs are:
From now on, these are the directories that I will be using on the post. Please adapt whenever necessary.
Next step is to create a symbolic link inside the libs dir that will point to the SDK:
# ln -s /usr/include/oracle/11.2/client64 /usr/lib/oracle/11.2/client64/include
Now, add some environment variables to your ~/.bashrc file:
Note that the last variable is pointing to /etc/oracle. You can point this to whatever directory you want. This variable tells the Oracle client where your TNSNAMES.ORA file is located (if you have one), so point it to wherever you will put the file.
Now, either open a new bash session, or just source your .bashrc file to initialise the variables:
$ source ~/.bashrc
2. Getting, building and installing TOra
Now you’ll probably want to get the TOra sources from your package manager, so first create a directory where the sources will be downloaded to and enter it. Then get the sources and dependencies:
$ apt-get source tora
(...) Sources downloaded
And as root:
# apt-get build-dep tora
Debian squeeze has TOra version 2.1.2, so:
$ cd tora-2.1.2
$ dpkg-buildpackage -us -uc -rfakeroot
Wait until compilation finishes. If all goes well, you’ll find a .deb package waiting to be installed in the parent directory:
$ cd ..
# dpkg -i tora_2.1.2-1_amd64.deb ## as root!
After installing the package, it’s time to try out and see if you have Oracle support. Run the software
If it complains about not being able to load libaio.so.1, you have to install the package libaio1 and try again.
Now, check that you see Oracle in the Connection Provider dropdown:
If so, compilation and installation is finished. Now it’s time to put a TNSNAMES.ORA in the $TNS_ADMIN directory and restart the software.
It’s also a good idea to put the package on hold, so that it does not get overwritten by the distro package during your next update:
# echo "tora hold" | dpkg --set-selections
Update per Matt Fischer’s suggestion: If aptitude is ignoring the “hold” command given to dpkg above, try
# aptitude hold tora
Update: If you get complaints about missing dependencies on libclntsh.so, please refer to the comment by mehturt on August 10 2011 below.
You’re ready to rock!