zoukankan      html  css  js  c++  java
  • 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指定。

    [root@h1 ~]# 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 文件夹,并进行安装:

    [root@h1 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
    [root@h1 soft]# rpm -ivh ClouderaImpalaODBC-2.5.15.1015-1.el6.x86_64.rpm 
    Preparing...                ########################################### [100%]
       1:ClouderaImpalaODBC     ########################################### [100%]
    [root@h1 soft]# 

    安装完毕后的文件在:/opt/cloudera/impalaodbc 文件夹,这个文件夹包括了安装文档、lib包、配置文件演示样例。

    [root@h1 impalaodbc]# pwd
    /opt/cloudera/impalaodbc
    [root@h1 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
    [root@h1 impalaodbc]# 


    设置驱动的环境变量:

    在 /etc/profile 最后加入:

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

    然后运行:source /etc/profile  

    使改动的脚本马上生效。

    拷贝:cloudera.impalaodbc.ini 到 /etc/文件夹:

    [root@h1 Setup]# pwd
    /opt/cloudera/impalaodbc/Setup
    [root@h1 Setup]# cp cloudera.impalaodbc.ini /etc/
    [root@h1 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

    [root@h1 ~]# 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



  • 相关阅读:
    Python3之random模块常用方法
    Go语言学习笔记(九)之数组
    Go语言学习笔记之简单的几个排序
    Go语言学习笔记(八)
    Python3之logging模块
    Go语言学习笔记(六)
    123. Best Time to Buy and Sell Stock III(js)
    122. Best Time to Buy and Sell Stock II(js)
    121. Best Time to Buy and Sell Stock(js)
    120. Triangle(js)
  • 原文地址:https://www.cnblogs.com/yfceshi/p/6931915.html
Copyright © 2011-2022 走看看