How to connect with HIVE via R with Kerberos keytab?

匆匆过客 提交于 2019-12-25 01:36:18

问题


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

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)

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)

What i am doing wrong?


回答1:


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".

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")

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 configuration: How to acess to HDFS via R?



来源:https://stackoverflow.com/questions/53618077/how-to-connect-with-hive-via-r-with-kerberos-keytab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!