下面是我试过的代码,但有错误请告诉我哪里出错了。
library("RJDBC")
.jinit()
.jaddClassPath("/home/r_work/hive_service.jar")
.jaddClassPath("/home/r_work/HiveJDBC4.jar")
.jaddClassPath("/home/r_work/libfb303-0.9.0.jar")
.jaddClassPath("/home/r_work/libthrift-0.9.0.jar")
.jaddClassPath("/home/r_work/log4j-1.2.14.jar")
.jaddClassPath("/home/r_work/hive_metastore.jar")
.jaddClassPath("/home/r_work/ql.jar")
.jaddClassPath("/home/r_work/slf4j-api-1.5.8.jar")
.jaddClassPath("/home/r_work/slf4j-log4j12-1.5.8.jar")
.jaddClassPath("/home/r_work/TCLIServiceClient.jar")
.jclassPath()
drv = JDBC("com.cloudera.hive.jdbc4.HS2Driver","~/r_work/hive_service.jar;~/r_work/HiveJDBC4.jar;~/r_work/libfb303-0.9.0.jar;~/r_work/libthrift-0.9.0.jar;~/r_work/log4j-1.2.14.jar;~/r_work/hive_metastore.jar;~/r_work/ql.jar;~/r_work/slf4j-api-1.5.8.jar;~/r_work/slf4j-log4j12-1.5.8.jar;~/r_work/TCLIServiceClient.jar","`")
#drv = JDBC("com.cloudera.hive.jdbc4.HS2Driver","~/r_work/HiveJDBC4.jar","`")
conn <- dbConnect(drv, "jdbc:hive2://grbd.com:10000/test_hive_db;AuthMech=1;KrbRealm=INTRANET.BARCAPINT.COM;KrbHostFQDN=grbd.com;KrbServicename=hive")
#conn <- dbConnect(drv, "jdbc:hive2://grbdwhd0017.intranet.barcapint.com:10000;AuthMech=1;KrbRealm=INTRANET.BARCAPINT.COM;KrbHostFQDN=grbdwhd0017.intranet.barcapint.com;KrbServicename=hive")
library(RHive)
> Sys.setenv(HIVE_Home= "ls /cloudera/parcels/lib/hive")
> Sys.setenv(HIVE_Lib= "ls /cloudera/parcels/lib/hive/lib")
> Sys.setenv(HIVE_HOME= "ls /cloudera/parcels/lib/hive")
> Sys.setenv(HIVE_LIB= "ls /cloudera/parcels/lib/hive/lib")
> Sys.setenv(HADOOP_HOME= "ls /cloudera/parcels/lib/hadoop")
> Sys.setenv(HADOOP_CONF = "ls /cloudera/parcels/lib/hadoop/etc/hadoop/hdfs-site.xml")
> Sys.setenv(HADOOP_LIB= "ls /cloudera/parcels/lib/hadoop/lib")
rhive.init()
> rhive.connect("grbd")
****错误:java.lang.ClassNotFoundException ****
答案 0 :(得分:0)
您只需使用RHIVE包
从R连接到hiveserver2即可以下是我使用过的命令。
Sys.setenv(HIVE_HOME = “/ USR /本地/蜂巢”) Sys.setenv(HADOOP_HOME = “/ USR /本地/ hadoop的”) rhive.env(ALL = TRUE) rhive.init() rhive.connect( “本地主机”)