Skip to content
Back to formatted view

Raw Message

Message-ID: <3E1C08ABE98D2946977745E01A1A376F0173C481@BANURBNA05.e2k.ad.ge.com>
Date: 2016-05-25T13:40:47Z
From: Kumar, Anoop (GE Corporate, consultant)
Subject: Connecting to Hive in Kerberos enabled hadoop cluster  from R

Hi All,

Request your help.

We are trying to connect to hive from R using Rstudio. Its a kerberos secured cluster. Code snippet is below.

==============

library(rJava)
library(RJDBC)

cp = c("/usr/hdp/2.3.2.0-2950/hive/lib/hive-jdbc.jar","/usr/hdp/2.3.2.0-2950/hadoop/lib/hadoop-common-2.7.1.2.3.2.0-2950.jar")
.jinit(classpath=cp)

drv <- JDBC("org.apache.hive.jdbc.HiveDriver",classPath = list.files("/usr/hdp/2.3.2.0-2950/hadoop/lib",pattern="jar$",full.names=T, recursive = TRUE),identifier.quote="`")

conn <- dbConnect(drv, "jdbc:hive2://host.node1.com:10000/default;principal=hive/shost.node1.com at node1.com<mailto:shost.node1.com at node1.com>", "", "")

show_databases <- dbGetQuery(conn, "show databases")

show_databases

==============

But we are getting the below error

Error in .jcall(drv at jdrv, "Ljava/sql/Connection;", "connect", as.character(url)[1],  :
  java.lang.NoClassDefFoundError: Could not initialize class org.apache.hadoop.security.UserGroupInformation

What are we missing here? A kerberos ticket is there in place. Shall we usekerberos  keytab inside R code? What is the function for ir. Also which hadoop libraries should we import for R and hive interaction?



Thanks & Regards,

Anoop Kumar K M