Installing Netezza Client and ODBC Driver In CentOS 7

IBM Netezza is a data warehouse appliance. It partially supports SQL-92 (SQL/2). Unfortunately the software is proprietary. Besides the limited articles on IBM Knowledge Center, it is quite hard to find help on the Stack Overflow. This is how I setup Netezza Linux client and ODBC driver in CentOS 7 (64-bit). Instruction for other Linux distribution should be similar. I use this driver in PHP applications.

Install Netezza Linux Client

Obtain the client package from the IBM Fix Central site (mine is nz-linuxclient-v7.2.1.3-P4.tar.gz). Make sure you perform the installation as root user. I have been running into issues when I use sudo.

mkdir netezza
tar -xf nz-linuxclient-v7.2.1.3-P4.tar.gz -C netezza/
cd netezza/linux/
./unpack
cd ../linux64/
./unpack

Note: when asked where the client should be installed, type "/usr/local/nz". It will save you lots of trouble.

Support 32-bit Binaries

All the executables (except nzodbcsql) are 32-bit. Install glibc.i686 to support execution of 32-bit applications.

yum install glibc.i686

Resolve 32-bit Dependencies

This is a 2-step process. First, determine missing dependencies. Lastly, install those dependencies.

Screenshot 2020-05-14 at 17.48.12.png

Navigate to /usr/local/nz/bin. Use ldd to list dependencies. Look out for "not found" as shown in picture above. Use yum provides to determine which package resolve a dependency and install it.

Screenshot 2020-05-14 at 17.56.41.png

Repeat the steps above to resolve all dependencies.

Test your setup: /usr/local/nz/bin/nzsql -h HOSTNAME -u USERNAME -d DBNAME -pw PASSWORD

This concludes installation of Linux client. Now we shall proceed with setting up Netezza ODBC driver.

Setup Environment Variables

Add the following to ~/.bashrc. I personally add it to a new file in /etc/profile.d/ (e.g. /etc/profile.d/netezza.sh).

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib46:/usr/local/nz/lib64
export PATH=$PATH:/usr/local/nz/bin64:/usr/local/nz/bin

Setting LD_LIBRARY_PATH is considered a bad practice, and it might break some applications but it is needed for this driver to work.

Install unixODBC

I have not tried iODBC. Let me in the comment if it works.

yum install unixODBC

Configure ODBC Driver

Append the following to the end of /etc/odbcinst.ini. Create this file if it does not exist.

[NetezzaSQL]
Driver           = /usr/local/nz/lib64/libnzodbc.so
Setup            = /usr/local/nz/lib64/libnzodbc.so
APILevel         = 1
ConnectFunctions = YYN
Description      = Netezza ODBC driver
DriverODBCVer    = 03.51
DebugLogging     = false
LogPath          = /tmp
UnicodeTranslationOption = utf8
CharacterTranslationOption = all
PreFetch         = 256
Socket           = 16384

That's it. You can start using Netezza ODBC driver in whatever programming language that supports ODBC. Remember to set "NetezzaSQL" as driver name in DSN string.

Creating odbc.ini

This step is optional. If you like to predefine data sources you can get a copy from my Gist (bit.ly/2At1MWn) and save it as ~/.odbc.ini. Make sure you set Driver to NetezzaSQL or /usr/local/nz/lib64/libnzodbc.so.

PHP ODBC

This is only applicable for PHP.

yum install php-odbc

Sample code

$conn = odbc_connect('DRIVER={NetezzaSQL};SERVER=127.0.0.1;DATABASE=DBNAME', 'USERNAME', 'PASSWORD');

[01000][unixODBC][Driver Manager]Can't open lib '/usr/local/nz/lib/libnzsqlodbc3.so'

Netezza Linux client package comes with sample odbcinst.ini, and it does not work for 64-bit environment. These are steps to resolve this issue:

  • Make sure correct path (/usr/local/nz/lib64) is exported in LD_LIBRARY_PATH environment variable.
  • In odbcinst.ini, make sure the value for both Driver and Setup is "/usr/local/nz/lib64/libnzodbc.so".
  • In odbc.ini, make sure the value for Driver is "NetezzaSQL" (preferred) or "/usr/local/nz/lib64/libnzodbc.so".