为 RODBC 安装 Cloudera Impala ODBC 驱动程序

Installing Cloudera Impala ODBC drivers for RODBC

我已尝试非常仔细地按照安装指南在 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 包获取到 运行 查询,所以我知道连接有效。任何帮助是极大的赞赏。谢谢!

原来是 yosemite 默认的 iODBC 驱动程序有问题。我最终重新安装了 mac os,并且一切正常。

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

安装mac ODBC 管理器

  1. http://www.odbcmanager.net/ 下载文件
  2. 安装后,从 Applications/Utilities
  3. 打开程序
  4. 点击"Drivers"然后点击"Add"
  5. 浏览到 impala 驱动程序,默认位置是: /opt/cloudera/impalaodbc/lib/universal/libclouderaimpalaodbc.dylib
  6. 添加系统 DSN
  7. 添加 DSN 名称,然后单击 "Add"
  8. 添加以下两个键值对:

    主机 your_host_name

    端口 21050

  9. 点击"OK"

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

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