Installing TOra with Oracle Support on Ubuntu 9.10 (Karmic Koala)

In this edition we’re faced with a new Ubuntu, new TOra 2.0, and new and exciting adventures, all of which I have stripped out so you can get this up and running quickly.

All in all, the build process turned out to be simpler than it had on previous versions all thanks to a much smarter build system. The scripts that debian-ize the packages are much more robust and also much more complex at first glance. There was no configure line to change in this one, it’s smart enough to pick up all the elements you need provided they are where the build expects them to be. One such item is the Oracle include path, which I will say more about shortly. Enough snappy patter, let’s get on with . . .

Installing TOra with Oracle support on Ubuntu 9.10 (Karmic Koala)

Conventions and Caveats

  • I use sudo for everything because logging in to root shells is just bad practice.
  • I plug vi whenever possible, because vi is the greatest (high five).
  • Commands issued are in pre-formatted text without any prompt gunk in front of them, so cut and paste to your heart’s content.
  • Output is also in pre-formatted text and I use it sparingly where relevant. Apt is chatty.
  • Some instructions are pasted from the previous versions so you will not need to refer to my last howto to get this working. I shamelessly did not rewrite some bits if there was no change.
  • When I say “dep”, I actually mean dependancy.

Environment

This is based on a 64-bit install of Ubuntu 9.10 using the Oracle 11 clients. The system itself is an AMD Athlon 64 7750 Black Box Editions at 2.7GHz with 4GB DDR2. I also touch on the 32-bit install using the 11.2 client because it was mentioned in comments for the previous edition. For the record, the only difference is in the environment variables.

The desktop I am running this time is the KDE4.3.2 that is shipped with Kubuntu 9.10 (one day away as I write this, but I am running the release candidate patched to current which should be close to the final release). I like it. Nuff said. There was no issue with KDE development libraries this time around since I did not hack and slash the desktop together. The scripts also detect KDE for you, so no changes to the configure script necessary.

Get the packages

Find an acceptable build location in your filesystem, cd to there and then get the tora source deb package. This bit should not be done with sudo or else you’ll run into build problems later because all the files are owned by root.


mkdir -p /path/to/deb/source/
cd /path/to/deb/source/
apt-get source tora

That should drop and unpack the TOra source in your current directory. Now get the Oracle packages. Get them from the Oracle site..

Again, the login you need is free to register. The files we want this time around are:

  • oracle-instantclient11.1-basiclite-11.1.0.7.0-1.x86_64.rpm
  • oracle-instantclient11.1-devel-11.1.0.7.0-1.x86_64.rpm
  • oracle-instantclient11.1-sqlplus-11.1.0.7.0-1.x86_64.rpm

For those using 32-bit, the lastest packages are these:

  • oracle-instantclient11.2-basiclite-11.2.0.1.0-1.i386.rpm
  • oracle-instantclient11.2-devel-11.2.0.1.0-1.i386.rpm
  • oracle-instantclient11.2-sqlplus-11.2.0.1.0-1.i386.rpm

Install the prerequisites and development libraries

Next we’ll want to install the build dependencies via apt. To do this, run the following simple command.


sudo apt-get build-dep tora

From there, we’ll get all the other things that we need to prevent the build from failing. The list is a bit slimmer than last time, and weighed in around 68MB if I recall correctly.


sudo apt-get install libqt3-mt-dev libqt3-compat-headers libqscintilla-dev build-essential g++ gcc autoconf automake flex zlib1g-dev docbook-xsl debhelper alien libaio1 dpatch fakeroot xsltproc texi2html texinfo libqt3-mt-psql libqt3-mt-odbc config-package-dev cmake qt4-dev-tools

Next install the Oracle clients. In the directory where you installed them run the following to convert and install the packages in one fell swoop.


cd /path/to/oracle/rpms

When I ran it this time around, I found that I had both 32- and 64-bit packages in the same directory, and alien did not like that. Best to filter down to just the arch we want.


sudo alien -i oracle*x86_64.rpm

or for 32-bit:


sudo alien -i oracle*i386.rpm

This will take a bit of time, but should turn out okay.

Now that we have the packages, the deps, and the sources, it’s time to set up

Environment Variables

Thanks to the new build scripts there is no longer a need to set the CFLAGS and CPPFLAGS environment variables. That was a nice surprise. We’re also not going to change the dynamic link library paths as we have in the past as it seems to be overkill, we’ll just specify it in the environment.

Here are the environment variables you’ll need. This is the only place where the instructions change depending on your version of Oracle and architecture.

For a 64-bit machine you’ll want to set this:


export ORACLE_HOME="/usr/lib/oracle/11.1/client64"
export LD_LIBRARY_PATH="${ORACLE_HOME}/lib"
export TNS_ADMIN="${ORACLE_HOME}"

For 32-bit using the new 11.2 instant client you need this instead:


export ORACLE_HOME="/usr/lib/oracle/11.2/client"
export LD_LIBRARY_PATH="${ORACLE_HOME}/lib"
export TNS_ADMIN="${ORACLE_HOME}"

For 32-bit and the 11.1 client use the above, but change 11.2 to 11.1.

Again, you will want to add the Oracle environment info (the last three lines above) to your .bashrc, so that they will be used after the required logout/login.

Again, for 64-bit use this:


echo export "ORACLE_HOME=/usr/lib/oracle/11.1/client64" >> ~/.bashrc
echo export "TNS_ADMIN=${ORACLE_HOME}" >> ~/.bashrc

And for 32-bit with 11.2 use this:


echo export "ORACLE_HOME=/usr/lib/oracle/11.1/client64" >> ~/.bashrc
echo export "TNS_ADMIN=${ORACLE_HOME}" >> ~/.bashrc

This will only take effect on next log-in. Until then, you can run TOra from the shell you install it in, as the menu will not work until you log out and in again.

Note: My install of Karmic did not have a .bashrc or .profile in my home directory by default. If this fails to work on next log-in, that’s a good place to look. To test it, log out and in again then run this in a terminal.


$ echo $ORACLE_HOME
/usr/lib/oracle/11.1/client64

Include path oddity

The last piece of the puzzle, which caused me the most grief, was the fact that the script could not find oci.h, which is an include header provided by the Oracle client. After much grinding of teeth and plumbing the depths of the scripts, I found that it was only looking in certain places for the file, places which did not exist on my system. It made some assumptions that may be right in certain conditions but not mine. I found the oci.h file and after a couple tries concocted a solution that does not require making any changes to the source or script—simply create a symbolic link to put the file where the script is looking.


sudo ln -s /usr/include/oracle/11.1/client64/ ${ORACLE_HOME}/include

Building and installing TOra

Go to your build directory and you’ll see there is a tora-2.0.0 directory. Change to this directory.


cd /path/to/deb/source/tora-2.0.0.0

Run the script to build the package.


fakeroot debian/rules binary

Those of you who have done this before will notice a marked difference in the look of the compile, complete with nifty progress counters that update as each file is processed. The results, however, are the same. On the test 64-bit machine, it took me seven minutes to compile the whole thing (while browsing and listening to music and other tasks); on my laptop it took about 30 (otherwise idle) minutes.

Once you are done, you should see the new deb package in the directory below where you are.


$ ls -al ../*.deb
-rw-r--r-- 1 hudson hudson 4900786 2009-10-28 18:47 ../tora_2.0.0-4build2_amd64.deb

And for you 32-bit people it would be tora_2.0.0-4build2_i386.deb.

Install it using the following (32-bit users can now extrapolate):


dpkg -i ../tora_2.0.0-4build2_amd64.deb

The Update Issue Again

This rehashed text brought to you compliments of me, the lazy blogger. A simpler way to stop the package from updating.


echo 'tora hold' | sudo dpkg --set-selections

End Game Redux

Don’t forget your tnsnames.ora. We set up the environment to use TNS_ADMIN=/usr/lib/oracle/11.1/client64 which means that tora will look for tnsnames.ora there. The easiest way I found was to get the production tnsnames.ora file from the Oracle server itself, and place it in the $TNS_ADMIN directory. Once you have done so, start TOra and enjoy. Remember to start it from the xterm session that has the environment variables set if you have not yet logged out/in.

Nifty KDE trick

I thought this was useful enough to repeat. I wanted it to work with my current menu without logging off. Time is money, and logging off means too much lost productivity. This still works the same in KDE 4.3.2 on Karmic. Here is what I did.

  1. Right click on the big blue “K” menu button.
  2. Select “Menu Editor”.
  3. In the KDE menu editor, on the left side, find the Development item and click the + to expand the tree.
  4. Right click the TOra and select Copy.
  5. Right click the TOra icon again and select Paste.
  6. Left click on the TOra-2 icon.
  7. In the command box enter

    ORACLE_HOME=/usr/lib/oracle/11.1/client64 LD_LIBRARY_PATH=/usr/lib/oracle/11.1/client64/lib TNS_ADMIN=/usr/lib/oracle/11.1/client64 tora
  8. Click the File menu, then Quit.
  9. Click the Save button to save your changes.

Now in the “K” menu click K->Applications->Development->TOra-2 and enjoy your selecting.

I have done a bit of testing and it’s working great. The last time I did this I had issues with advanced functions like the schema browser, which work properly now. I am not sure if this is because they fixed something, or I broke something. Either way, it’s all good.

Please feel free to ask questions or post your own experiences in the comments. My test environments are limited, so there may be issues that did not arise for me. Also, I am game to tackle writing up similar guides for other distributions like CentOS or Fedora, so let me know if there is interest. I do it on Ubuntu since it makes a better desktop than most others.