R连接Hive

1,下载相关工具并安装

        R下载地址:https://cloud.r-project.org/,选择对应的系统版本进行下载

        R开发工具推荐使用RStudio,下载地址:https://www.rstudio.com/products/rstudio/download/

2,R访问Hive配置  

  加载连接信息:drv<-JDBC("org.apache.hive.jdbc.HiveDriver",  list.files("HIVE_LIB_DIR",pattern="jar$", full.names=TRUE, recursive=TRUE))

        建立连接:conn <- dbConnect(drv,"jdbc:hive2://hostname:10000/db_test;user=xxx;password=xxx")

        查看表:dbListTables(conn)

其中:HIVE_LIB_DIR为R访问Hive时所依赖的jar文件路径名,jar文件参考目录如下:

commons-collections-3.2.2.jar
commons-configuration-1.9.jar
commons-lang-2.6.jar
commons-logging-1.1.jar
commons-logging-api-1.1.jar
guava-11.0.2.jar
hadoop-auth-2.6.0.jar
hadoop-common-2.6.0.jar
hive-cli-0.11.0.jar
hive-common-1.1.0.jar
hive-jdbc-1.1.0.jar
hive-service-1.1.0.jar
hive-shims-0.23-1.1.0.jar
hive-shims-common-1.1.0.jar
hive_metastore.jar
hive_service.jar
httpclient-4.2.5.jar
httpcore-4.2.5.jar
libfb303-0.9.0.jar
libthrift-0.9.0.jar
log4j-1.2.14.jar
mysql-connector-java-5.1.38.jar
ql.jar
slf4j-api-1.5.11.jar
slf4j-log4j12-1.5.11.jar
TCLIServiceClient.jar
zookeeper-3.4.6.jar

你可能感兴趣的:(R连接Hive,hive)