ITeye博客

Impala ODBC 安装笔记

daizj · 2015-05-13 10:44 · impala · 编程语言 · odbc · Markdown

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 plaincopy在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 plaincopy在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 plaincopy在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 plaincopy在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 plaincopy在CODE上查看代码片派生到我的代码片

 

  1. # Generic ODBCInstLib
  2. #   iODBC
  3. #ODBCInstLib=libiodbcinst.so
  4. #   SimbaDM / unixODBC
  5. ODBCInstLib=libodbcinst.so

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

 

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

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

 

[javascript] view plaincopy在CODE上查看代码片派生到我的代码片

 

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

 

四、验证安装是否成功

执行 isql -v impalaodbc

 

[javascript] view plaincopy在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

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。