Impala ODBC 安装笔记

Impala在线文档介绍了 Impala ODBC接口安装和配置
http://www.cloudera.com/content/cloudera-content/cloudera-docs/CDH5/latest/Impala/Installing-and-Using-Impala/ciiu_impala_odbc.html
Impala ODBC 驱动下载地址:
http://www.cloudera.com/content/support/en/downloads/connectors.html

本文详细讲解了CentOS-6.5-x86_64环境下 Impala ODBC的安装和使用。

 

 

一、检查unixODBC是否安装:

rpm -qa|grep unixODBC

如果没有安装,使用下面的命令安装:

 

yum install unixODBC

 

yum install unixODBC-devel

使用odbcinst命令查看unixODBC配置文件路径,不同版本的unixODBC配置文件路径是不同的,如果是源代码方式安装unixODBC,也可以通过编译参数--sysconfdir指定。

 

[javascript]  view plain copy 在CODE上查看代码片 派生到我的代码片
 
  1. [root@h1 ~]# odbcinst -j  
  2. unixODBC 2.2.14  
  3. DRIVERS............: /etc/odbcinst.ini  
  4. SYSTEM DATA SOURCES: /etc/odbc.ini  
  5. FILE DATA SOURCES..: /etc/ODBCDataSources  
  6. USER DATA SOURCES..: /root/.odbc.ini  
  7. SQLULEN Size.......: 8  
  8. SQLLEN Size........: 8  
  9. SQLSETPOSIROW Size.: 8  

二、安装Impala ODBC驱动

下载ClouderaImpalaODBC-2.5.15.1015-1.el6.x86_64.rpm,保存到:/home/soft 目录,并进行安装:

 

[javascript]  view plain copy 在CODE上查看代码片 派生到我的代码片
 
  1. [root@h1 soft]# ll  
  2. total 16232  
  3. -rw-r--r--. 1 root root 16619934 Aug 24 06:37 ClouderaImpalaODBC-2.5.15.1015-1.el6.x86_64.rpm  
  4. [root@h1 soft]# rpm -ivh ClouderaImpalaODBC-2.5.15.1015-1.el6.x86_64.rpm   
  5. Preparing...                ########################################### [100%]  
  6.    1:ClouderaImpalaODBC     ########################################### [100%]  
  7. [root@h1 soft]#   


安装完成后的文件在:/opt/cloudera/impalaodbc 目录,这个目录包含了安装文档、lib包、配置文件示例。

 

 

[javascript]  view plain copy 在CODE上查看代码片 派生到我的代码片
 
  1. [root@h1 impalaodbc]# pwd  
  2. /opt/cloudera/impalaodbc  
  3. [root@h1 impalaodbc]# ll  
  4. total 1016  
  5. -rwxr-xr-x. 1 root root 1007048 Apr 21 12:21 Cloudera ODBC Driver for Impala Install Guide.pdf  
  6. -rwxr-xr-x. 1 root root   12003 Apr 21 12:21 Cloudera-EULA.txt  
  7. drwxr-xr-x. 3 root root    4096 Aug 24 07:15 ErrorMessages  
  8. -rwxr-xr-x. 1 root root    3261 Apr 21 12:21 Readme.txt  
  9. -rwxr-xr-x. 1 root root    2350 Apr 21 12:21 Release Notes.txt  
  10. drwxr-xr-x. 2 root root    4096 Aug 24 07:15 Setup  
  11. drwxr-xr-x. 3 root root    4096 Aug 24 07:15 lib  
  12. [root@h1 impalaodbc]#   

 

 

设置驱动的环境变量:

在 /etc/profile 最后添加:

export LD_LIBRARY_PATH=/usr/local/lib:/opt/cloudera/impalaodbc/lib/64

然后执行:source /etc/profile  

使修改的脚本立即生效。

拷贝:cloudera.impalaodbc.ini 到 /etc/目录:

 

[javascript]  view plain copy 在CODE上查看代码片 派生到我的代码片
 
  1. [root@h1 Setup]# pwd  
  2. /opt/cloudera/impalaodbc/Setup  
  3. [root@h1 Setup]# cp cloudera.impalaodbc.ini /etc/  
  4. [root@h1 Setup]#   


修改:/etc/cloudera.impalaodbc.ini 中的如下条目:

 

 

[javascript]  view plain copy 在CODE上查看代码片 派生到我的代码片
 
  1. # Generic ODBCInstLib  
  2. #   iODBC  
  3. #ODBCInstLib=libiodbcinst.so  
  4.  
  5. #   SimbaDM / unixODBC  
  6. ODBCInstLib=libodbcinst.so  

也就是说不使用iODBC , 使用 unixODBC

 

三、修改/etc/odbc.ini 文件

参照 /opt/cloudera/impalaodbc/Setup/odbc.ini ,  在/etc/odbc.ini 添加如下的内容:

 

[javascript]  view plain copy 在CODE上查看代码片 派生到我的代码片
 
  1. [impalaodbc]  
  2.  
  3. # Description: DSN Description.  
  4. # This key is not necessary and is only to give a description of the data source.  
  5. Description=Cloudera ODBC Driver for Impala (64-bit) DSN  
  6.  
  7. # Driver: The location where the ODBC driver is installed to.  
  8. Driver=/opt/cloudera/impalaodbc/lib/64/libclouderaimpalaodbc64.so  
  9.  
  10. # The DriverUnicodeEncoding setting is only used for SimbaDM  
  11. # When set to 1, SimbaDM runs in UTF-16 mode.  
  12. # When set to 2, SimbaDM runs in UTF-8 mode.  
  13. #DriverUnicodeEncoding=2  
  14.  
  15. # Values for HOST, PORT, KrbFQDN, and KrbServiceName should be set here.  
  16. # They can also be specified on the connection string.  
  17. HOST=172.16.230.152  
  18. PORT=21050  
  19. Database=default  
  20.  
  21. # The authentication mechanism.  
  22. # 0 - no authentication.  
  23. # 1 - Kerberos authentication  
  24. # 2 - Username authentication.  
  25. # 3 - Username/password authentication.  
  26. # 4 - Username/password authentication with SSL.  
  27. AuthMech=0  
  28.  
  29. # Kerberos related settings.  
  30. KrbFQDN=  
  31. KrbRealm=  
  32. KrbServiceName=  
  33.  
  34. # Username/password authentication with SSL settings.  
  35. UID=  
  36. PWD=  
  37. CAIssuedCertNamesMismatch=1  
  38. TrustedCerts=/opt/cloudera/impalaodbc/lib/64/cacerts.pem  
  39.  
  40. # Specify the proxy user ID to use.  
  41. #DelegationUID=  
  42.  
  43. # General settings  
  44. TSaslTransportBufSize=1000  
  45. RowsFetchedPerBlock=1000  
  46. SocketTimeout=0  
  47. StringColumnLength=32767  
  48. UseNativeQuery=0  

四、验证安装是否成功

执行 isql -v impalaodbc

 

[javascript]  view plain copy 在CODE上查看代码片 派生到我的代码片
 
  1. [root@h1 ~]# isql -v impalaodbc  
  2. +---------------------------------------+  
  3. | Connected!                            |  
  4. |                                       |  
  5. | sql-statement                         |  
  6. | help [tablename]                      |  
  7. | quit                                  |  
  8. |                                       |  
  9. +---------------------------------------+  
  10. SQL> select * from tab1;  
  11. [S1000][unixODBC][Cloudera][ImpalaODBC] (110) Error while executing a query in Impala: [HY000] : Error: Error: could not match input  
  12. [ISQL]ERROR: Could not SQLPrepare  
  13. SQL> select * from tab1   
  14. +------------+------+-------------------------+------------------------------+  
  15. | id         | col_1| col_2                   | col_3                        |  
  16. +------------+------+-------------------------+------------------------------+  
  17. | 1          | 1    | 123.123                 | 2012-10-24 08:55:00          |  
  18. | 2          | 0    | 1243.5                  | 2012-10-25 13:40:00          |  
  19. | 3          | 0    | 24453.325               | 2008-08-22 09:33:21.123000000|  
  20. | 4          | 0    | 243423.325              | 2007-05-12 22:32:21.334540000|  
  21. | 5          | 1    | 243.325                 | 1953-04-22 09:11:33          |  
  22. +------------+------+-------------------------+------------------------------+  
  23. SQLRowCount returns -1  
  24. 5 rows fetched  

注意:执行的sql最后不要加封号。

 

这样配置后,C/C++程序就可以通过unixODBC访问Impala中的数据了。

五、License问题

默认安装的Impala ODBC是评估版的,需要购买license,参见安装文档 Cloudera ODBC Driver for Impala Install Guide.pdf 中的这样一段话:

If you are installing a driver with an evaluation license and you have purchased a perpetual license, then copy the License.lic file you received via e-mail into the /opt/cloudera/impalaodbc/lib/32 or /opt/cloudera/impalaodbc/lib/64 folder, depending on the version of the driver you installed.

评估时为多长时间,目前还没找到答案。或者让你一直评估吧:)

 

本文转载: http://blog.csdn.net/yangzhaohui168/article/details/38800803

 

 

猜你喜欢

转载自daizj.iteye.com/blog/2210720