Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created on 08-25-2016 09:12 PM
Article
Goals
Notes/Requirements
Ubuntu
root@srai-odbc-ubuntu:~# apt-get update Get:1 http://security.ubuntu.com trusty-security InRelease [65.9 kB] .... Ign http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en_US Fetched 11.2 MB in 6s (1,623 kB/s) Reading package lists... Done
CentOS
[centos@node1 ~]$ sudo yum repolist Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile repo id repo name status base CentOS-6 - Base 6,696 epel Extra Packages for Enterprise Linux 6 - x86_64 12,192 extras CentOS-6 - Extras 62 updates CentOS-6 - Updates 457
Installing UnixODBC on Ubuntu
root@srai-odbc-ubuntu:~# apt-get install unixodbc Reading package lists... Done Building dependency tree Reading state information... Done ..... Setting up unixodbc (2.2.14p2-5ubuntu5) ... Setting up odbcinst (2.2.14p2-5ubuntu5) ... Processing triggers for libc-bin (2.19-0ubuntu6.4) ... root@srai-odbc-ubuntu:~#
root@srai-odbc-ubuntu:~/ODBC# wget http://www.unixodbc.org/unixODBC-2.3.4.tar.gz --2016-08-25 16:34:30-- http://www.unixodbc.org/unixODBC-2.3.4.tar.gz Resolving www.unixodbc.org (www.unixodbc.org)... 87.106.19.214 Connecting to www.unixodbc.org (www.unixodbc.org)|87.106.19.214|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1830660 (1.7M) [application/x-gzip] Saving to: ‘unixODBC-2.3.4.tar.gz’ 100%[========================================================================================================================================>] 1,830,660 390KB/s in 5.2s 2016-08-25 16:34:35 (346 KB/s) - ‘unixODBC-2.3.4.tar.gz’ saved [1830660/1830660]
root@srai-odbc-ubuntu:~/ODBC# tar -xzf unixODBC-2.3.4.tar.gz
cd unixODBC-2.3.4
./configure --prefix=/opt/odbc/unixodbc --exec-prefix=/opt/odbc/unixodbc/oth --bindir=/opt/odbc/unixodbc/bin --sbindir=/opt/odbc/unixodbc/sbin --libexecdir=/opt/odbc/unixodbc/libexec --sysconfdir=/opt/odbc/unixodbc/etc --libdir=/opt/odbc/unixodbc/lib --includedir=/lib --includedir=/lib64 make make install
# find /usr/local -name isql /usr/local/bin/isql
# cd /opt/odbc/unixodbc/bin # ./odbcinst -j unixODBC 2.3.4 DRIVERS............: /usr/local/etc/odbcinst.ini SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini FILE DATA SOURCES..: /usr/local/etc/ODBCDataSources USER DATA SOURCES..: /root/.odbc.ini SQLULEN Size.......: 8 SQLLEN Size........: 8 SQLSETPOSIROW Size.: 8
NOTE: If you see this error
/usr/local/bin/odbcinst: error while loading shared libraries: libodbcinst.so.2: cannot open shared object file: No such file or directory
..this can be due to libraries not being found, but they might exist on the system. Perform the following steps to verify and fix this
# ldd /opt/odbc/unixodbc/odbcinst linux-vdso.so.1 => (0x00007fff33dfe000) libodbcinst.so.2 => not found libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f7f739e2000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7f7361c000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f7f73418000) /lib64/ld-linux-x86-64.so.2 (0x00007f7f73e23000) # find /opt -name libodbcinst.so.2
/opt/odbc/unixodbc/lib/libodbcinst.so.2
# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/odbc/unixodbc/lib # ldd /opt/odbc/unixodbc/odbcinst linux-vdso.so.1 => (0x00007fff33dfe000) libodbcinst.so.2 => /opt/odbc/unixodbc/lib/libodbcinst.so.2 (0x00007f7f73c06000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f7f739e2000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7f7361c000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f7f73418000) /lib64/ld-linux-x86-64.so.2 (0x00007f7f73e23000)
Installing & Configure Hive ODBC on Ubuntu
# dpkg -i hive-odbc-native_2.1.2.1002-2_amd64.deb (Reading database ... 54835 files and directories currently installed.) Preparing to unpack hive-odbc-native_2.1.2.1002-2_amd64.deb ... Unpacking hive-odbc-native (2.1.2.1002-2) over (2.1.2.1002-2) ... Setting up hive-odbc-native (2.1.2.1002-2) ... #
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib:/lib64:/opt/odbc/unixodbc/lib
root@srai-odbc-ubuntu:/opt/odbc/unixodbc/etc# ls -lrth /opt/odbc/unixodbc/etc total 4.0K -rw-r--r-- 1 root root 0 Aug 25 18:00 odbcinst.ini -rw-r--r-- 1 root root 0 Aug 25 18:00 odbc.ini drwxr-xr-x 2 root root 4.0K Aug 25 18:00 ODBCDataSources
# cp /usr/lib/hive/lib/native/hiveodbc/Setup/odbc.ini /opt/odbc/unixodbc/etc/odbc.ini # cp /usr/lib/hive/lib/native/hiveodbc/Setup/odbcinst.ini /opt/odbc/unixodbc/etc/odbcinst.ini
Here is the sample configuration output
[hivedb] Driver=/usr/lib/hive/lib/native/Linux-amd64-64/libhortonworkshiveodbc64.so HOST=node1.hortonworks.com PORT=10000 HiveServerType=2 AuthMech=1 UID=hive KrbHostFQDN=kerb.hortonworks.com KrbServiceName=hive KrbRealm=HWX.COM
export ODBCINI=/opt/odbc/unixodbc/odbc.ini export ODBCSYSINI=/opt/odbc/unixodbc export HORTONWORKSHIVEINI=/usr/lib/hive/lib/native/Linux-amd64-64/hortonworks.hiveodbc.ini
# Generic ODBCInstLib # iODBC #ODBCInstLib=libiodbcinst.so <<<<<<< Comment This # SimbaDM / unixODBC ODBCInstLib=libodbcinst.so <<<<<<< Uncomment
Testing the connectivity
# kinit -k -t /tmp/hive.service.keytab hive/[email protected] # klist
# /opt/odbc/unixodbc/bin/isql hivedb -v
# /opt/odbc/unixodbc/bin/isql hivedb +---------------------------------------+ | Connected! | | | | sql-statement | | help [tablename] | | quit | | | +---------------------------------------+ SQL> show tables; +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | tab_name | +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | csvinternal | | cvsexternal | | sample_07 | | src | | test | | testabc | | testnormal | | tgt | +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ SQLRowCount returns -1 8 rows fetched SQL> select * from test limit 5; +------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | col1 | col2 | +------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | 1 | one | | 1 | one | | 10 | ten | | 11 | eleven | | 10 | ten | +------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ SQLRowCount returns -1 5 rows fetched SQL>
The process of installing UnixODBC on CentOS precisely the same with the exception of how firewalls are turned off. Everything else is virtually the same.
Enabling Debug Logging
# vi $HORTONWORKSHIVEINI # vi /usr/lib/hive/lib/native/Linux-amd64-64/hortonworks.hiveodbc.ini
LogLevel=6 LogPath=/opt/odbc/unixodbc/logs
# ls -lrth /opt/odbc/unixodbc/logs/ total 796K -rw-r--r-- 1 root root 9.5K Aug 25 20:51 HortonworksHiveODBCDriver.log -rw-r--r-- 1 root root 784K Aug 25 20:51 HortonworksHiveODBCDriver_connection_0.log
Hope this helps!!
Created on 01-04-2017 08:18 AM
Thanks a lot for the article.It helped me a lot.
There is a small correction in the above.
/etc was missing in the path.
Created on 02-20-2017 09:50 AM
KrbHostFQDN should be be set to FQDN of the Hive Server or _HOST in case of multiple HS2 servers.
This attribute should not be set to Kerberos server.
Could we please update this article to avoid confusions?