连接到Hive从远程计算机上的R启用了Kerberos

问题描述 投票:1回答:1

我在我的本地机器上运行了一个R,我的蜂巢服务器在使用cloudera的aws机器上配置并启用了kerberos。我现在无法使用JDBC连接从本地R实例连接到hive服务器。

我想知道是否有任何可用的选项可以帮助我从R连接到配置单元服务器?我尝试了以下代码并收到错误。

library(RJDBC)
drv1 <- JDBC("org.apache.hive.jdbc.HiveDriver",list.files("Rjars/jars/hive_jdbc/",pattern="jar$",full.names=T))
con<-dbConnect(drv,'jdbc:hive2://ec2-xx-xx-xx-xxx.us-west-2.compute.amazonaws.com:10000/default;principal=hive/[email protected]',"username","pwd")

控制台输出

Jun 09, 2016 3:34:07 PM org.apache.hive.jdbc.Utils parseURL
INFO: Supplied authorities: ec2-xx-xx-xxx-xxx.us-west-2.compute.amazonaws.com:10000
Error in .verify.JDBC.result(jc, "Unable to connect JDBC to ", url) : 
  Unable to connect JDBC to jdbc:hive2://ec2-xx-xx-xx-xxx.us-west-2.compute.amazonaws.com:10000/default;principal=hive/[email protected] (Could not initialize class org.apache.hadoop.security.UserGroupInformation)
Jun 09, 2016 3:34:07 PM org.apache.hive.jdbc.Utils parseURL
INFO: Resolved authority: ec2-xx-xx-xxx-xxx.us-west-2.compute.amazonaws.com:10000
r jdbc hive kerberos cloudera
1个回答
0
投票

你必须做相当于“kinit”

在我的例子中,您可以使用与您正在使用的cloudera版本等效的hadoop-common库,并执行以下指示:

Sys.setenv(KRB5_CONFIG = "/conf/krb5.conf")
Sys.setenv(sun.security.jgss.debug="FALSE");

conf=.jnew ("org.apache.hadoop.conf.Configuration")
conf$set("hadoop.security.authentication", "Kerberos")
ugi=J("org.apache.hadoop.security.UserGroupInformation")
ugi$setConfiguration (conf)
ugi$loginUserFromKeytab("webApp@MYCOMPANY","conf/webapp.keytab")
© www.soinside.com 2019 - 2024. All rights reserved.