Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R JDBC Kerberos #57

Open
darshanpandya-kogentix opened this issue Apr 26, 2018 · 1 comment
Open

R JDBC Kerberos #57

darshanpandya-kogentix opened this issue Apr 26, 2018 · 1 comment
Assignees
Labels
documentation Request for documentation or clarification

Comments

@darshanpandya-kogentix
Copy link

Hello ,

I am trying to connect R to Hive (kerberos enabled) .. Please let me know if the following is the right approach. If yes, I am running into an issue which is not giving enough information to debug.

Thank you for your help in advance.

hadoop.class.path = list.files(path=c("/usr/hdp/2.6.2.0-205/hadoop"),pattern="jar", full.names=T);
hive.class.path = list.files(path=c("/usr/hdp/current/hive-client/lib"),pattern="jar", full.names=T);
hadoop.lib.path = list.files(path=c("/usr/hdp/current/hive-client/lib"),pattern="jar",full.names=T);
mapred.class.path = list.files(path=c("/usr/hdp/current/hadoop-mapreduce-client/lib"),pattern="jar",full.names=T);
cp = c(hive.class.path,hadoop.lib.path,mapred.class.path,hadoop.class.path)
.jinit(classpath=cp, parameters="-DRJDBC.debug=true")
drv <- JDBC("org.apache.hive.jdbc.HiveDriver","hive-jdbc.jar",identifier.quote="`")
conn <- dbConnect(drv, "jdbc:hive2://myserver.corp.server.com:10000/default;principal=hive/[email protected]","","")
Error in .jcall(drv@jdrv, "Ljava/sql/Connection;", "connect", as.character(url)[1], :
java.lang.NoClassDefFoundError: Could not initialize class org.apache.hive.jdbc.HiveConnection

@adamsma
Copy link

adamsma commented Sep 19, 2019

I know this is a bit of an old issue, but I recently had to set up a connection using Kerberos. To get it to work before creating the driver, I had to create a UserGroupInformation class and use the loginUserFromKeytab method. Something along the lines of:

  conf <- rJava::.jnew("org.apache.hadoop.conf.Configuration")
  conf$set("hadoop.security.authentication", "kerberos")

  ugi <- rJava::J("org.apache.hadoop.security.UserGroupInformation")
  ugi$setConfiguration(conf)
  ugi$loginUserFromKeytab("<PRINCIPAL>", "<PATH_TO_KEYTAB>")

Then set up the Hive driver and connect.

@s-u s-u self-assigned this Mar 18, 2021
@s-u s-u added the documentation Request for documentation or clarification label Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Request for documentation or clarification
Projects
None yet
Development

No branches or pull requests

3 participants