return to OCLUG Web Site
A Django site.
April 15, 2010

Pythian
pythian
» Installing TOra with Oracle Support on Ubuntu 10.04 (Lucid Lynx)

Once again into the breach. The release of Ubuntu 10.04 is at hand. I’ve been playing with “Lucid” for a couple of months now but since we’re in beta2 with the release candidate soon to follow, I thought I would really sit down and get my normal app stack working including TOra. All in all the instructions are mostly the same as last time around, with a couple of new improvements, caveats and quid pro quo.

Environment

This one is being written using the 32 bit version of everything. I tend to use my laptop as a testbed and I have not upgraded any 64 bit machines as of yet. The instructions will be the same, you just need to make some environmental changes to get it working with 64 bit systems. I’ll try to update the blog when I do it myself next month, or check my previous guides and extrapolate as necessary.

Get the packages

First off we’ll create new directories for the packages and get the sources. Ubuntu 10.04 is using TOra 2.1.1. If you want the full list of changes in this version then you are out of luck, you can check the NEWS file on the TOra svn site which states only “lots of notes missing for 2.x series”.


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

Now get the Oracle packages. Get them from the Oracle site. Since there’s a new version of the oracle client I am using the lastest and greatest.

  • 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

Now we’ll get all the other build tools and libraries that we’ll need for this to work. This list is exactly the same as last time.


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 downloaded them run the following to convert and install the packages in one fell swoop.


cd /path/to/oracle/rpms
sudo alien -i *386.rpm

Environment Variables

Now that we have all the bits we need, we set up the build environment. First we set up the oracle home environment and library path.


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

As before you’ll want to add these into your system wide profile or .bashrc in order to use TOra. Just to change things up a bit, this time around we’ll add it to the default profile. Oddly this was not working for me directly with sudo, so you will need to get a root shell going to make it happen.


sudo -s
[sudo] password for $you:
echo export ORACLE_HOME="/usr/lib/oracle/11.2/client" >> /etc/profile
echo export LD_LIBRARY_PATH="${ORACLE_HOME}/lib" >> /etc/profile
echo export TNS_ADMIN="${ORACLE_HOME}" >> /etc/profile
exit

And now we have a new player. The last time around I had you create a symlink to the includes for oracle, this time It’s much easier to just use the CMAKE environment variables to point to the include files we need.


export CMAKE_INCLUDE_PATH=/usr/include/oracle/11.2/client

Now on to the main event.

Building and installing TOra

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


cd /path/to/tora/tora-2.1.1/

Run the script to build the package.


fakeroot debian/rules binary

Depending on your system speed, take a break while the compile runs. Once done, proceed to install it like so.


dpkg -i ../tora_2.1.1-1_i386.deb

The Update Issue

This time around I am going to break out the method of stopping updates to a few methods.

  • Method 1: Using dpkg

    Supports: apt-get, Synaptic

    This is the way I have been doing it through all the blogs in this series. The problem I found with this method is that some GUI package managers do not seem to respect the hold the way I think they should. So I can hold it all I want, but the second I let KPackageKit do an upgrade I am sunk. It also will not survive a dist-upgrade, not even using apt.

    Luckily for me I almost always do it on the command line using apt, so for those inclined as I am you simply need to run this command.


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

    To ensure the change took, look at the package status like so. The response from dpkg is bolded.


    $ dpkg-query --status tora|grep Status
    Status: hold ok installed

    When you are done you should see this if you try to run an upgrade via apt.


    $ sudo apt-get upgrade
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following packages have been kept back:
    tora

    If it does not hold the package back, then check your status as above.

  • Method 2: Using aptitude

    Supports: aptitude, KPackageKit

    This method is similar to the above, but has the annoying habit of removing packages when you do it. Sure it’s only removing packages that you no longer need (considered unused by aptitude like old kernels). I personally like to control when packages are removed and adding a hold to a package is not the right time to uninstall things.

    If, after all that, you still want to try it then here is the command you need.


    sudo aptitude hold tora

    I did some searching and I see no method to display this hold status using aptitude. If someone can add a method for this in comments it would be helpful.

  • Method 3: Using $GUI front end

    I know there are quite a number of different package managers out there and most probably support methods 1 and/or 2. If not then you’ll need to figure that one our on your own. Feel free to add the package manager and method in comments.

  • Method 4: Super Guerilla Tactics(tm)

    Supports: Everything

    This method is easy but is not really for the faint of heart. It has the advantage of never having to worry about upgrades again, at least until a much newer version comes out. This method involves changing the package version number before compiling to create a package with a version number that should be higher than anything available in the repository. This needs to be done before you compile, or you can go back and compile it again.

    First, add an entry to the debian changelog file.


    cd /path/to/tora/tora-2.1.1
    vi debian/changelog

    You can see that this file has a series of change log entries with dates and version numbers. Add a new entry to the top of the file as I did with the below example. Be cautious of the spacing and blank lines between entries as the compiler will barf if they are even one space off. Pay particular attention to the 2 spaces between the email address and the date which cannot be replicated on a web page correctly due to html parsing (multiple spaces are not allowed, not even after proper punctuation :O)


    tora (2.1.1-10) unstable; urgency=low

    * Version incremented to avoid upgrades.

    -- Brad Hudson <none@none.net> Thu, 15 Apr 2010 14:00:00 +0500

    tora (2.1.1-1) unstable; urgency=low

    * New upstream version.

    -- Michael Meskes <meskes@debian.org> Thu, 19 Nov 2009 15:18:19 +0100

    Save and exit the file. As you can see, all I did was change the packaged version to -10, which is higher than -1 through -9, meaning there would have to be 9 more official releases before it’ll overwrite your custom package. I did not update the actual code version (everything before the -) so if a version 2.1.2-1 comes out you’ll need to watch for it. These number can be changed to anything you want however (as long as it’s higher), so if you wanted to make sure it was never upgraded even for major version changes, you could set the version to this.


    tora (5.1.1-1) unstable; urgency=low

    The program code will not change through any of this, just the package name.

    Now that you’ve modified the changelog, go back to the build step and recompile everything. When you are done the build can install the shiny new version like so.


    sudo dpkg -i ../tora_2.1.1-10_i386.deb

End Game Re-Redux

Don’t forget your tnsnames.ora. We set up the environment to use TNS_ADMIN=/usr/lib/oracle/11.2/client 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.

Once again the build was pretty smooth. I have replicated these instructions 3 times over the course of writing this so there should be very few problems for you if you follow step by step.

As I stated before I could write these up for other distros if anyone is interested. Leave comments if you are.

References

The TOra homepage
Installing TOra with Oracle support on Ubuntu 8.04LTS (Hardy Heron)
Installing TOra with Oracle support on Ubuntu 9.04 (Jaunty Jackalope)
Installing TOra with Oracle Support on Ubuntu 9.10 (Karmic Koala)
Kubuntu linux

April 24, 2009

Pythian
pythian
» End of School with Linux; Ubuntu 9.04 Released

Hi folks. I am back for the second in what will eventually be a long line of infrequent updates. Did you miss me?

End of School with Linux

OCLUG (The Ottawa Canada Linux Users Group) is putting on an event called—you guessed it—End of School with Linux. This is happening on April 28, 2009 starting at 11am at the University of Ottawa in the SITE building, room C0136. The purpose of the event is to help people with their Linux systems, install Linux, fix issues, and just generally help out in the community. Your humble blogger will be there, manning the booth from 1200-1600, so come on down. And tell a friend, too.

More details can be found at the CSSA’s page. Click here for a map of the campus.

Also check out the OCLUG home page.

Ubuntu 9.04 Released

Ubuntu 9.04 was released today. I have not yet looked at any reviews of the release candidates, but I am on my way out to pick up some new hardware on which to install it tonight.

If you were not on the sites downloading it early today you may have to wait, as most mirrors are very busy. If you have a newsgroup account then check out alt.binaries.cd.images—the ISO for 32-bit and 64-bit are there in both desktop and server flavours. For some reason, the Kubuntu and Edubuntu releases are not in the newsgroups, but you can always install the meta-packages after installing from the main ubuntu dist using apt-get install kubuntu.

Over the next few days I will be doing an install of the 64-bit version on my hefty(ish) new system, and a 32-bit install on my sorely-outdated laptop. I will post results.

Don’t forget to check out the Ubuntu web site.

One final thought

Did I mention I am going to get new hardware tonight? It’s been years! I am blogging and doing work, but all I hear in my head is “EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE”! It’s a wonderful kind of feeling.

Till next time.

December 12, 2008

Pythian
pythian
» Installing TOra with Oracle support on Ubuntu 8.04LTS (Hardy Heron)

The situation is this. I am a system administrator working in a world of DBAs. This is not a bad thing, but sometimes tasks crossover and I need to connect to Oracle. In light of this, I have been using the Oracle SQL Developer GUI in KDE for some time now.

While the functionality of the product is quite slick I find it painful to work with. The major source of my pain is the slow interface due to its dependence on Java. I mean seriously, the screen refreshes are abysmal. I found that the more I used it, the more I needed a lighter, faster alternative.

One day a while back, I noticed that the boss was running TOra. He’s more of a DBA than I am, and I tend to trust his opinion on such things, so I asked him about it. He told me it was quite good, and so I decided I should try it out. I installed it on my Kubuntu desktop, fired it up, and much to my chagrin, found that it had no Oracle support. A bit of digging turned up that Oracle support was not included in the Debian package.

I had to do something about it. A bit more research brought me to some useful sites, a couple of which I will reference later, but after going through the process, I found that none of them had all the bits together in one nifty package. This is an attempt to change that.

After bouncing back and forth on some of these steps, fixing environment issues, decoding compiler errors, and generally fiddling, I went back to my notes and terminal histories and figured out what I feel is the best order for the process. This is the streamlined version of maybe two hours of fiddling. I hope it will help someone avoid the pitfalls (there are 8-bit crocodiles below!).

And so I humbly present to you . . . 

Installing TOra with Oracle support on Ubuntu 8.04LTS (Hardy Heron)

Environment

Based on a 32-bit install of Ubuntu 8.04 LTS using the Oracle 11 clients. AMD 3200+ processor with 1GB of RAM and a bizarre assortment of franken-hardware.

I could have done this on 8.10 but I prefer to stick to the long term support releases. I may try it on my 8.10 laptop at a later date and update the guide.

Conventions

  • I use sudo for everything because logging in to root shells is just bad practice.
  • I plug vi whenever possible, mostly to annoy emacs people.
  • I did this all in a KDE desktop, which means that some things I say may sound like I use KDE.
  • Commands issued are in pre-formatted text without any prompt gunk in front of them, so cut and paste to your hearts content.
  • Output is also in pre-formatted text and I use it sparingly where relevant. No one needs to see the list of packages that apt-get wants to autoremove, nor how many updates I should be installing.

Get the packages

Find an acceptable build location in your filesystem, cd to there and then get the tora source deb package.

sudo apt-get source tora

Get the Oracle client RPMs from the Oracle 11 client download page. All the packages you need are on one page, but you need a log-in to get them. Accounts are free. The files we want are:

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

Install the prerequisites and development libraries

Install alien and all the dependencies that this build will need to work. Alien is a cool little tool for converting .rpm to .deb files and more.

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

This will install a lot of other dependencies, just go with it.

If you want to build with KDE support then do the following (having never done this without the KDE support, I’m not really sure what the differences are (perhaps someone can enlighten me in a comment).

sudo apt-get install kdebase-dev

This will probably install even more dependencies than above, but hey, you’ve come this far. Now that we have all the prerequisites in place, let’s get Oracle installed.

Change directory to where you downloaded the Oracle RPMs.

cd oracle
ls -al
total 18912
drwxr-xr-x 2 root   root       4096 2008-12-10 00:35 .
drwxr-xr-x 4 domito domito     4096 2008-12-10 07:58 ..
-rw-r--r-- 1 root   root   17958287 2008-12-10 00:28 oracle-instantclient11.1-basiclite-11.1.0.7.0-1.i386.rpm
-rw-r--r-- 1 root   root     578817 2008-12-10 00:27 oracle-instantclient11.1-devel-11.1.0.7.0-1.i386.rpm
-rw-r--r-- 1 root   root     782162 2008-12-10 00:27 oracle-instantclient11.1-sqlplus-11.1.0.7.0-1.i386.rpm

Now we are going to convert them to .deb and install them all in one shot.

sudo alien -i *.rpm

The output will look like this.

        dpkg --no-force-overwrite -i oracle-instantclient11.1-basiclite_11.1.0.7.0-2_i386.deb
Selecting previously deselected package oracle-instantclient11.1-basiclite.
(Reading database ... 172382 files and directories currently installed.)
Unpacking oracle-instantclient11.1-basiclite (from oracle-instantclient11.1-basiclite_11.1.0.7.0-2_i386.deb) ...
Setting up oracle-instantclient11.1-basiclite (11.1.0.7.0-2) ...

Processing triggers for libc6 ...
ldconfig deferred processing now taking place
        dpkg --no-force-overwrite -i oracle-instantclient11.1-devel_11.1.0.7.0-2_i386.deb
Selecting previously deselected package oracle-instantclient11.1-devel.
(Reading database ... 172399 files and directories currently installed.)
Unpacking oracle-instantclient11.1-devel (from oracle-instantclient11.1-devel_11.1.0.7.0-2_i386.deb) ...
Setting up oracle-instantclient11.1-devel (11.1.0.7.0-2) ...
        dpkg --no-force-overwrite -i oracle-instantclient11.1-sqlplus_11.1.0.7.0-2_i386.deb
Selecting previously deselected package oracle-instantclient11.1-sqlplus.
(Reading database ... 172446 files and directories currently installed.)
Unpacking oracle-instantclient11.1-sqlplus (from oracle-instantclient11.1-sqlplus_11.1.0.7.0-2_i386.deb) ...
Setting up oracle-instantclient11.1-sqlplus (11.1.0.7.0-2) ...

Environment setup

Now that we have Oracle and the development libraries all in place, we need to get the system to use the libraries and know where Oracle lives.

To permanently add the Oracle library path, called oracle.conf, and add the Oracle library path. Create a new config file for oracle in /etc/ld.so.conf.d called oracle and add the Oracle library path.

sudo echo /usr/lib/oracle/11.1/client/lib > /etc/ld.so.conf.d/oracle.conf

Now rebuild your library cache. No output is good output for ldconfig.

sudo ldconfig

Now set your environment so tora can find Oracle. We’ll also add one that will tell tora where to find the tnsnames.ora file.

export ORACLE_HOME=/usr/lib/oracle/11.1/client
export LD_LIBRARY_PATH=/usr/lib/oracle/11.1/client/lib
export TNS_ADMIN=/usr/lib/oracle/11.1/client

For good measure I would add this to your login scripts so that tora will not bomb when you run it. Depending on your shell you might need to do this to ~/.profile. I use bash, because it rules. And yes, I know there are prettier ways to get this done, but this works.

echo "export ORACLE_HOME=/usr/lib/oracle/11.1/client" >> ~/.bashrc
echo "export LD_LIBRARY_PATH=/usr/lib/oracle/11.1/client/lib" >> ~/.bashrc
echo "export TNS_ADMIN=/usr/lib/oracle/11.1/client" >> ~/.bashrc

Now we should be ready to build.

A word about the environment

If you are using tora then you are in XWindows. Likely you did all this in a terminal window using xterm or konsole. We created these environment variables in the terminal which means they are local to the terminal window itself. If you try to run TOra from the menu, it will fail. That is why we added them into the ~/.bashrc file. The .bashrc file will not take effect for your X desktop until you log out and back in again, there’s no way around that. So until you log out/in you can just run TOra from the command line in your terminal window. Bringing up a new xterm should source your .bashrc file and get the environment variables too.

Building and installing TOra

Unpack tora:

tar -zxvf tora_1.3.22.orig.tar.gz

cd to the tora source dir:

cd tora-1.3.22/

Change the configure command arguments in debian/rules using your favorite editor (which surely must be vi). Find line 20, which says:

./configure --prefix=/usr --without-oracle --without-rpath --disable-new-check --with-kde --enable-libsuffix=

And shift-D, i in the following (non vi users delete the line and insert this one).

./configure --prefix=/usr --with-instantclient --with-oracle-includes=/usr/include/oracle/11.1/client --without-rpath --disable-new-check --with-kde --enable-libsuffix=

If you avoided the minute discomfort of installing the KDE development libraries, or just plain do not want KDE support, use this one (I would also suggest this if you run into some bizarre KDE related error when compiling. It’s been known to happen. I think there’s a support group.):

./configure --prefix=/usr --with-instantclient --with-oracle-includes=/usr/include/oracle/11.1/client --without-rpath --disable-new-check --without-kde --enable-libsuffix=

Now it’s time for the main event, we’re going to compile it. How you ask? Thusly! From right where you are in the root of the tora source tree run this stunningly complex command:

debian/rules binary

This will take a bit of waiting now, but there’s nothing for it. On my out-of-date Athlon XP 3200+, the whole process took 12m27.674s. Just ballparking here.

Once the build is complete you are ready to install tora. Do it like so:

sudo dpkg -i tora_1.3.22-5_i386.deb

Selecting previously deselected package tora.
(Reading database ... 172036 files and directories currently installed.)
Unpacking tora (from tora_1.3.22-5_i386.deb) ...
Setting up tora (1.3.22-5) ...

But Mr Science, won’t apt just clobber my custom package when it updates?

I’m glad you asked that Billy. Get me some coffee and a cigarette and I’ll explain combustion. Ahem.

Normally, yes. in fact when I was testing this I found that apt-get will prefer a repository package to my own even though they were the same version. To fix this we need to add an entry to the apt preferences configuration:

man apt_preferences  # :)

Edit /etc/apt/preferences (it will likely be a new file) and add the following lines:

Package: tora
Pin: version *
Pin-Priority: 50

What this says is that for the package tora, any version it will assign priority 50. Priority 50 means, essentially, that it will not be installed unless it’s not already installed, and you have to ask for it by name. What that means for you is that auto-updates will not destroy all your hard work.

End Game

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

This is where I leave off. The running and connecting and such I leave in the hands of you and the TOra documentation.

All in all I was pleased with how the whole process turned out. I have been using TOra and like it so far. I have not yet been able to find stored procedures in it, but that will come. I also had a crash when I brought up the help, but I am not sure if that is a bug and will need to look into it. It compiled cleanly, so I do not blame it on a compilation error.

Coming up

I’m not great at keeping a regular blogging schedule. I am trying to mend my ways though. That being said, I have one in the works dealing with a statement I read on another blog, that Ubuntu was becoming slower with each release. I captured some performance data before I did a fresh install of 8.10, so I will share the results if they are interesting. I also have a nifty little one about VMware in a hosted ISP environment. Stay tuned.

References

The TOra homepage

Installing TOra with Oracle Support on Ubuntu Community Forums

APT HOWTO