Wednesday, March 2, 2011

Teradata Client - Fedora Core 14 Build Example C++

Background:
The motivation of this project has to do with a desire of a colleague of mine to do development work on an installation of Fedora Core 14. The headache of this process has been left out. This is the abbreviated version that will show the process involved in getting a connection up and going as fast as possible.

Keep in mind that FC is not at this time a supported distro for Teradata!

We are starting with a Fedora Core 14 32bit guest machine running in VMWare Workstation. Host is Windows XP SP3. All libraries required to get VMWare tools installed and running have been pre-installed so there may be some dependencies already in place that are not listed. The Fedora core instance is fully updated as of today. SELinux has also already been disabled.

It's worth mentioning that we are listening to many Jay-Z albums while writing / figuring this out.

Lets Go! - Download Driver Package

Alright, first thing is first, lets start out by downloading the Teradata drivers. Go to:
www.teradata.com/downloadcenter/
Follow ODBC -> Linux and download the correct package (TTU 13.10 LINUX-INDEP tdodbc.13.10.00.01 in my case)

Keep going until you download the .tar.gz package (tdodbc__LINUX_INDEP.13.10.00.01-1.tar.gz)

Make sure to first read the accompanying README file before proceeding it will detail any dependencies that *may* need to be installed on your OS. Since FC is not supported we cannot rely on this documentation to be all inclusive but it can provide great hints.

Once you have downloaded the drivers, move into the directory holding the downloaded file. Create a directory to hold expanded files and then untar the archive:


[cj@fc14 Downloads]$ mkdir /tmp/td
[cj@fc14 Downloads]$ mv tdodbc__LINUX_INDEP.13.10.00.01-1.tar.gz /tmp/td/
[cj@fc14 Downloads]$ cd /tmp/td
[cj@fc14 td]$ tar xof tdodbc__LINUX_INDEP.13.10.00.01-1.tar.gz

You should have now have 3 component archives and readme files in your working directory.
tdodbc*
tdicu*
TeraGSS*

TeraGSS has redhat and suse versions.

Take a moment out to remember that FC is a Redhat OS and expand each archive:

[cj@fc14 td]$ tar xof tdicu__linux_indep.13.10.00.00-1.tar.gz 
[cj@fc14 td]$ tar xof TeraGSS_redhatlinux-i386__linux_i386.13.10.00.02-1.tar.gz
[cj@fc14 td]$ tar xof tdodbc__linux_x64.13.10.00.01.tar.gz

Installing Teradata Driver Packages:

Now install the tdicu package:

[cj@fc14 td]$ cd tdicu
[cj@fc14 tdicu]$ sudo rpm -ihv tdicu-13.10.00.00-1.noarch.rpm 

Output:
Adding TD_ICU_DATA environment variable to /etc/profile file.
Adding TD_ICU_DATA environment variable to /etc/csh.login file.

Since the package updated /etc/profile, lets first load the profile changes into our shell (just in case):
[cj@fc14 tdicu]$ source /etc/profile

Next lets install TeraGSS:
[cj@fc14 tdicu]$ cd ../TeraGSS/
[cj@fc14 TeraGSS]$ sudo rpm -ihv TeraGSS_redhatlinux-i386-13.10.00.02-1.i386.rpm

Output:
Preparing...                ########################################### [100%]
   1:TeraGSS_redhatlinux-i38########################################### [100%]
/usr/teragss/redhatlinux-i386/13.10.00.02/bin/tdgssconfig: error while loading shared libraries: libstdc++-libc6.2-2.so.3: cannot open shared object file: No such file or directory

Alright, so we are missing a dependecy, lets use yum to install that:
[cj@fc14 TeraGSS]$ sudo yum provides libstdc++-libc6.2-2.so.3

Output:
compat-libstdc++-296-2.96-143.i686 : Compatibility 2.96-RH standard C++
                                   : libraries
Repo        : fedora
Matched from:
Other       : libstdc++-libc6.2-2.so.

[cj@fc14 TeraGSS]$ sudo yum install compat-libstdc++-296-2.96-143.i686

Finally lets install the tdodbc package:
[cj@fc14 td]$ cd TeraGSS
[cj@fc14 TeraGSS]$ cd ../tdodbc
[cj@fc14 tdodbc]$ sudo rpm -ihv tdodbc-13.10.00.01-1.noarch.rpm

Output:
/var/tmp/rpm-tmp.9paHwf: /opt/teradata/client/13.10/odbc_32/bin/set_default_version: /usr/bin/ksh: bad interpreter: No such file or directory

Hmmm... its looking for korn shell, lets install that package from yum:
[cj@fc14 tdodbc]$ sudo yum install ksh

Really quick lets see where FC has put ksh:
[cj@fc14 tdodbc]$ which ksh

Output:
/bin/ksh

That is not going to work for us because the package is looking for ksh in /usr/bin/ksh , lets go ahead and create a link so that the Teradata installer can work:
[cj@fc14 tdodbc]$ sudo ln -s /bin/ksh /usr/bin/ksh

Now lets uninstall the tdodbc package and reinstall it to make sure we don't run into any more problems:
[cj@fc14 tdodbc]$ sudo rpm -e tdodbc
[cj@fc14 tdodbc]$ sudo rpm -ihv tdodbc-13.10.00.01-1.noarch.rpm

Perfect!

Building Example C++ Program:

Now, lets skip a bunch of explanation and get to the point.
The ODBC driver does not work in FC (again, you can read more if you would like once I post the blog). But, we can reach the teradata database using the C++ example provided by the good folks at Teradata. Lets take a look, go to the sample directory provided by the ODBC package, lets look at the C++ example:
[cj@fc14 tdodbc]$ cd /opt/teradata/client/13.10/odbc_32/samples/C++/

A makefile is provided so lets run build the example using make
[cj@fc14 C++]$ sudo make

Output:
/usr/bin/g++   -m32 -Wno-deprecated  -DLINUX -DVG_UNIX  -DODBCVER=0x0350    -I/opt/teradata/client/13.10/odbc_32/include -c -o ./adhoc.o adhoc.cpp
make: /usr/bin/g++: Command not found

K, we need to install the gnu c++ compiler:
[cj@fc14 C++]$ sudo yum install gcc-c++

One more time lets try running make:
[cj@fc14 C++]$ sudo make

Output:
g++: /usr/lib/libstdc++.so.5: No such file or directory

Using the method above again we find out that compat-libstdc++-33-3.2.3-68.i686 provides the libstdc++.so.5 library required:
[cj@fc14 C++]$ sudo yum install compat-libstdc++-33-3.2.3-68.i686

One more time on that make:
[cj@fc14 C++]$ sudo make

All looks good, the executable has been build and we now have the 'adhoc' executable. Lets go ahead and run it and see if we can connect (fill in all required fields when prompted):

Output:
{error} STATE=HY000, CODE=0, MSG=[Teradata][ODBC Teradata Driver] Major Status=0x04bd Minor Status=0x20800002-[terasso]Cannot load TDGSS library.

Hmmm.... Lets take a look at what this executable is trying to access since 'TDGSS library' is not inspiring my mind to a solution.

We are going to need to try and get a better look at what the adhoc program is trying to access. The easiest way to do this is to install strace and watch program accesses:

[cj@fc14 C++]$ sudo yum install strace
Once the install is finished re-run the adhoc program with strace:
[cj@fc14 C++]$ strace ./adhoc 2>&1 | less

Output:
stat64("/usr/teragss/redhatlinux-i386/client/etc/tdgssconfig.bin", 0xbf77613c) =
 -1 ENOENT (No such file or directory)

Ahh, OK so adhoc is looking for the presence of a file called tdgssconfig.bin that does not exist on the OS. I'm not really going to go into detail regarding how long this took me to figure out but the solution is to do the following:
[cj@fc14 C++]$ sudo /opt/teradata/teragss/redhatlinux-i386/13.10.00.02/bin/run_tdgssconfig

Output:
 Output has been written to Binary file "/opt/teradata/teragss/redhatlinux-i386/13.10.00.02/bin/../etc/tdgssconfig.bin"

Awesome! Now lets go ahead and run the adhoc program again:
[cj@fc14 C++]$ ./adhoc

Output:
...ODBC connection successful.
ODBC version        = -03.52.0000-
DBMS name           = -Teradata-
DBMS version        = -12.00.0317  12.00.03.17D-
Driver name         = -tdata.so-
Driver version      = -13.10.00.01-
Driver ODBC version = -03.51-
Enter SQL string:
 
FIN:

Congratulations to us, this is awesome we now have an executable on a FC 14 machine that is capable of talking with our Teradata SQL server.

A big thank you to my girlfriend for giving me the time to share this garbage this evening, and a thank you to Kanye West for offering me the Jam for the whole process.

1 comment:

  1. Thanks for this. I didn't have your exact problem but this greatly helped me diagnose a 32/64 bit config issue with the 13.10 driver bundle from Teradata.

    Gracias

    ReplyDelete