为RODBC安装Cloudera Impala ODBC驱动程序

时间:2015-03-22 22:24:19

标签: r odbc cloudera impala

我试过非常仔细地按照安装指南在Mac上为R设置Impala Cloudera ODBC驱动程序,但不断收到以下错误消息:

In odbcDriverConnect("DSN=Impala ODBC Driver") :
[RODBC] ERROR: state IM002, code 0, message [unixODBC][Driver
Manager]Data source name not found, and no default driver specified

这就是我所做的。对于下面引用的每个文件,我确保该文件存在于该位置。

http://www.cloudera.com/content/cloudera/en/downloads/connectors/impala/odbc/impala-odbc-v2-5-23.html

下载并安装Impala ODBC驱动程序
brew install unixodbc
odbcinst -j 

unixODBC 2.3.2
DRIVERS............: /usr/local/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/etc/ODBCDataSources
USER DATA SOURCES..: /Users/summerrae/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8

指出DYLD库路径变量:

export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/opt/cloudera/impalaodbc/lib/universal

echo "export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/opt/cloudera/impalaodbc/lib/universal/" >> ~/.bashrc

已编辑/usr/local/etc/odbc.ini:

[ODBC Data Sources]
# Use this name in your connection string 
Impala DSN=Impala ODBC Driver
[Impala DSN]
# Driver: The location where the ODBC driver is installed to. 
Driver=/opt/cloudera/impalaodbc/lib/universal/libclouderaimpalaodbc.dylib
# Values for HOST, PORT, Database 
HOST=myhost (changed name here for security)
PORT=21050
Database=default

Edited /user/local/etc/odbcinst.ini: 
[ODBC Drivers]
Impala ODBC Driver=Installed
[Impala ODBC Driver]
Description=Impala ODBC Driver
Driver=/opt/cloudera/impalaodbc/lib/universal/libclouderaimpalaodbc.dylib

已编辑/opt/cloudera/impalaodbc/lib/universal/cloudera.impalaodbc.ini:

[Driver]
## - Note that this default DriverManagerEncoding of UTF-15 
## is for unixODBC. 
DriverManagerEncoding=UTF-16
ErrorMessagesPath=/opt/cloudera/impalaodbc/ErrorMessages/
LogLevel=0
LogPath=

## - Note that the path to your ODBC Driver Manager 
## must be specified in DYLD_LIBRARY_PATH.
# unixODBC 
ODBCInstLib=libiodbcinst.dylib

将导出的路径变量导出到〜/ .bashrc:

#add full path to odbc.ini and add to bashrc
export ODBCINI=/usr/local/etc/odbc.ini
echo "export ODBCINI=/etc/odbc.ini" >> ~/.bashrc

#add directory path to odbcinst.ini and add to bashrc
export ODBCSYSINI=/usr/local/etc/
echo "export ODBCSYSINI=/etc/odbcinst.ini" >> ~/.bashrc

#add full path to cloudera.impalaodbc.ini and add to bashrc
export CLOUDERAIMPALAINI=/opt/cloudera/impalaodbc/lib/universal/cloudera.impalaodbc.ini
echo "export CLOUDERAIMPALAINI=/opt/cloudera/impalaodbc/lib/universal/cloudera.impalaodbc.ini" >> ~/.bashrc

在R:

install.packages("RODBC")
library(RODBC)
#connect using impala DSN
conn <- odbcConnect("Impala DSN")

我已经完成了我能找到的每个教程都能让它发挥作用。我能够使用Python连接到相同的服务器和参数,我能够使用RImpala连接到同一个服务器,但是不能让RImpala包运行查询,所以我知道连接有效。任何帮助是极大的赞赏。谢谢!

2 个答案:

答案 0 :(得分:2)

对于默认使用优胜美地的iODBC驱动程序来说,这是一个问题。我最终重新安装了mac os,一切都很好。

作为替代方案,我还发现你可以:

安装mac ODBC管理器

  1. http://www.odbcmanager.net/
  2. 下载文件
  3. 安装完成后,从“应用程序/实用程序”
  4. 打开该程序
  5. 点击&#34; Drivers&#34;然后&#34;添加&#34;
  6. 浏览到impala驱动程序,默认位置为: /opt/cloudera/impalaodbc/lib/universal/libclouderaimpalaodbc.dylib
  7. 添加系统DSN
  8. 添加DSN名称,然后点击&#34;添加&#34;
  9. 添加以下两个键值对:

    HOST your_host_name

    PORT 21050

  10. 点击&#34;确定&#34;

  11. 使用您在上面创建的DSN名称与RODBC连接。

答案 1 :(得分:0)

您的问题是驱动程序安装指向/ usr / local / etc文件夹中的文件以进行配置,而您试图修改该驱动程序随附的文件。我遇到了同样的问题,我只在/ usr / local / etc中配置了.ini文件,并且可以连接较少的DNS。