TOra with Oracle support on Debian squeeze

21 02 2011

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[64], while the SDK is under /usr/include/oracle/<version>/client[64]. I am using Oracle version 11.2 64-bit, so my dirs are:

  • /usr/lib/oracle/11.2/client64
  • /usr/include/oracle/11.2/client64

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:

export ORACLE_BASE=/usr/lib/oracle/11.2
export ORACLE_HOME=$ORACLE_BASE/client64
export TNS_ADMIN=/etc/oracle
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/include/oracle/11.2/client64:/usr/lib/oracle/11.2/client64/lib

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

$ tora

If it complains about not being able to load, 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, please refer to the comment by mehturt on August 10 2011 below.

You’re ready to rock!




7 responses

28 02 2011

Thanks! It’s working also in Ubuntu 10.04 Lucid Lynx.

17 03 2011
Matt Fisher

This worked flawlessly in Debian Squeeze. Thank you for taking the time to post this procedure.

19 03 2011

Sure thing. I battled with this for quite a while and then I had to retry the procedures over and over again for not having documented it.

Great to know that this post is helping others!

24 03 2011
Matt Fisher

One minor improvement would be to also issue an aptitude hold command (since aptitude seems to ignore dpkg’s hold setting):

# aptitude hold tora

31 03 2011

I had problems with aptitude actually ignoring its own hold command in the past, so I learned to use either dpkg or wajig for that.

Thanks for the tip anyway. I updated the post.


10 08 2011

Thanks, this worked for me as well on Debian sid; except I needed to create my own debian/ with DEB_DH_SHLIBDEPS_ARGS=–dpkg-shlibdeps-params=–ignore-missing-info, because it was complaining about missing dependencies on

24 03 2017

Thanks, this worked for me on Debian jessie. I also installed libqt4-sql-mysql, mysql-client and libmysqlclient-dev before creating the deb package to get mysql support (#aptitude install libqt4-sql-mysql libmysqlclient-dev mysql-client).

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: