1. 程式人生 > >Impala ODBC 安裝筆記

Impala ODBC 安裝筆記

cif 命令 cte 5.1 版本號 mod 在線 soc guid

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指定。

[[email protected] ~]# odbcinst -j
unixODBC 2.2.14
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8

二、安裝Impala ODBC驅動

下載ClouderaImpalaODBC-2.5.15.1015-1.el6.x86_64.rpm,保存到:/home/soft 文件夾,並進行安裝:

[[email protected] soft]# ll
total 16232
-rw-r--r--. 1 root root 16619934 Aug 24 06:37 ClouderaImpalaODBC-2.5.15.1015-1.el6.x86_64.rpm
[[email protected] soft]# rpm -ivh ClouderaImpalaODBC-2.5.15.1015-1.el6.x86_64.rpm 
Preparing...                ########################################### [100%]
   1:ClouderaImpalaODBC     ########################################### [100%]
[[email protected]
/* */ soft]#
安裝完畢後的文件在:/opt/cloudera/impalaodbc 文件夾,這個文件夾包括了安裝文檔、lib包、配置文件演示樣例。

[[email protected] impalaodbc]# pwd
/opt/cloudera/impalaodbc
[[email protected] impalaodbc]# ll
total 1016
-rwxr-xr-x. 1 root root 1007048 Apr 21 12:21 Cloudera ODBC Driver for Impala Install Guide.pdf
-rwxr-xr-x. 1 root root   12003 Apr 21 12:21 Cloudera-EULA.txt
drwxr-xr-x. 3 root root    4096 Aug 24 07:15 ErrorMessages
-rwxr-xr-x. 1 root root    3261 Apr 21 12:21 Readme.txt
-rwxr-xr-x. 1 root root    2350 Apr 21 12:21 Release Notes.txt
drwxr-xr-x. 2 root root    4096 Aug 24 07:15 Setup
drwxr-xr-x. 3 root root    4096 Aug 24 07:15 lib
[[email protected] impalaodbc]# 


設置驅動的環境變量:

在 /etc/profile 最後加入:

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

然後運行:source /etc/profile

使改動的腳本馬上生效。

拷貝:cloudera.impalaodbc.ini 到 /etc/文件夾:

[[email protected] Setup]# pwd
/opt/cloudera/impalaodbc/Setup
[[email protected] Setup]# cp cloudera.impalaodbc.ini /etc/
[[email protected] Setup]# 

改動:/etc/cloudera.impalaodbc.ini 中的例如以下條目:

# Generic ODBCInstLib
#   iODBC
#ODBCInstLib=libiodbcinst.so

#   SimbaDM / unixODBC
ODBCInstLib=libodbcinst.so

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


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

參照 /opt/cloudera/impalaodbc/Setup/odbc.ini , 在/etc/odbc.ini 加入例如以下的內容:

[impalaodbc]

# Description: DSN Description.
# This key is not necessary and is only to give a description of the data source.
Description=Cloudera ODBC Driver for Impala (64-bit) DSN

# Driver: The location where the ODBC driver is installed to.
Driver=/opt/cloudera/impalaodbc/lib/64/libclouderaimpalaodbc64.so

# The DriverUnicodeEncoding setting is only used for SimbaDM
# When set to 1, SimbaDM runs in UTF-16 mode.
# When set to 2, SimbaDM runs in UTF-8 mode.
#DriverUnicodeEncoding=2

# Values for HOST, PORT, KrbFQDN, and KrbServiceName should be set here.
# They can also be specified on the connection string.
HOST=172.16.230.152
PORT=21050
Database=default

# The authentication mechanism.
# 0 - no authentication.
# 1 - Kerberos authentication
# 2 - Username authentication.
# 3 - Username/password authentication.
# 4 - Username/password authentication with SSL.
AuthMech=0

# Kerberos related settings.
KrbFQDN=
KrbRealm=
KrbServiceName=

# Username/password authentication with SSL settings.
UID=
PWD=
CAIssuedCertNamesMismatch=1
TrustedCerts=/opt/cloudera/impalaodbc/lib/64/cacerts.pem

# Specify the proxy user ID to use.
#DelegationUID=

# General settings
TSaslTransportBufSize=1000
RowsFetchedPerBlock=1000
SocketTimeout=0
StringColumnLength=32767
UseNativeQuery=0

四、驗證安裝是否成功

運行 isql -v impalaodbc

[[email protected] ~]# isql -v impalaodbc
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> select * from tab1;
[S1000][unixODBC][Cloudera][ImpalaODBC] (110) Error while executing a query in Impala: [HY000] : Error: Error: could not match input
[ISQL]ERROR: Could not SQLPrepare
SQL> select * from tab1 
+------------+------+-------------------------+------------------------------+
| id         | col_1| col_2                   | col_3                        |
+------------+------+-------------------------+------------------------------+
| 1          | 1    | 123.123                 | 2012-10-24 08:55:00          |
| 2          | 0    | 1243.5                  | 2012-10-25 13:40:00          |
| 3          | 0    | 24453.325               | 2008-08-22 09:33:21.123000000|
| 4          | 0    | 243423.325              | 2007-05-12 22:32:21.334540000|
| 5          | 1    | 243.325                 | 1953-04-22 09:11:33          |
+------------+------+-------------------------+------------------------------+
SQLRowCount returns -1
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



Impala ODBC 安裝筆記