如何通过带有Kerberos keytab的R与HIVE连接? [英] How to connect with HIVE via R with Kerberos keytab?

查看:880
本文介绍了如何通过带有Kerberos keytab的R与HIVE连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过R远程连接到Hive服务器,并执行身份验证,我使用Kerberos keytab文件.

I am trying to connect to a Hive server via R remotely, and to perform the authentication i use a Kerberos keytab file.

.jcall("RJavaTools","Ljava/lang/Object;","invokeMethod", cl,:java.io.IOException:登录失败 来自keytab的antonio.silva@HADOOPREALM.LOCAL C:/用户/antonio.silva/桌面/jars/antonio.silva.keytab: javax.security.auth.login.LoginException:空(68)

Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, : java.io.IOException: Login failure for antonio.silva@HADOOPREALM.LOCAL from keytab C:/Users/antonio.silva/Desktop/jars/antonio.silva.keytab: javax.security.auth.login.LoginException: null (68)

但是当我尝试通过keytab登录用户时,会出现错误.

But when i try to login the user via keytab, the error appears.

#loading libraries

library("RJDBC")

hadoop.class.path <- list.files(path = c("C:/Users/antonio.silva/Desktop/jars/hadoop/"), pattern = "jar", full.names = T)
hive.class.path <- list.files(path = c("C:/Users/antonio.silva/Desktop/jars/hive/"), pattern = "jar", full.names = T)
class.path = c(hadoop.class.path,hive.class.path)
.jinit(classpath=class.path)
conf = .jnew("org.apache.hadoop.conf.Configuration")
conf$set("hadoop.security.authentication", "kerberos")
ugi = J("org.apache.hadoop.security.UserGroupInformation")
ugi$setConfiguration(conf)
path = "C:/Users/antonio.silva/Desktop/jars/antonio.silva.keytab"
ugi$loginUserFromKeytab('antonio.silva@HADOOPREALM.LOCAL', path)

我做错了什么?

推荐答案

我找到了解决方案,事实证明,我需要将MIT Kerberos conf文件(krb5.conf)放在Java目录"〜\ Java中\ jre1.8.0_192 \ lib \ security".

I found the solution, it turns out, I needed the MIT Kerberos conf file (krb5.conf) to be placed in the java directory ""~\Java\jre1.8.0_192\lib\security".

将文件粘贴到目录中之后,我可以成功执行连接并连接到Hive服务器,除了先前发布的代码外,还使用以下代码:

After pasting the file in the directory, I was able to perform the connection successfully and connected to the Hive server, with the use of the following code in addition of the code published earlier:

drv <- JDBC("org.apache.hive.jdbc.HiveDriver")
conn <- dbConnect(drv, "jdbc:hive2://hivename:10000/default;principal=hive/_HOST@HADOOPREALM.LOCAL")

当需要通过R与HDFS进行连接时,此凭据验证有效.在这里,我给出了有关连接以及为使用R​​读取和写入HDFS服务器中的文件所需进行的配置的答案.

This credentials validations are valid when it is needed to perform a connection via R to the HDFS, where I placed an answer about the connection and the configurations needed to do in order to Read and Write the files in the HDFS server with R.

HDFS配置:如何通过R访问HDFS?

这篇关于如何通过带有Kerberos keytab的R与HIVE连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆