Sam
Sam

Reputation: 1237

Hive JDBC connection issues with Kerberos authentication - R

I am trying to connect Hive via JDBC using RJDBC package in R. Hive is configured with Kerberos authentication. i am using CDH 5.6.0. Hive version is 1.1.0. i am using following JARS

hive-jdbc-1.1.0-cdh5.6.0-standalone
hadoop-common-2.6.0-cdh5.6.0

my code was

library(RJDBC) drv <- JDBC("com.cloudera.hive.jdbc4.HS2Driver",list.files("Jars/",pattern="jar$",full.names=T)) url.dbc = paste0("jdbc:hive2://xx.xx.xx.xx:10000/default;principal=hive/[email protected]"); conn=dbConnect(drv,url.dbc,"username","password")

while executing this code i am getting following error,

Error in .jcall(drv@jdrv, "Ljava/sql/Connection;", "connect", as.character(url)[1], : java.sql.SQLException: [Cloudera][HiveJDBCDriver](500164) Error initialized or created transport for authentication: Peer indicated failure: Unsupported mechanism type PLAIN.

i am struck up here long time, Kindly help me on this error

Upvotes: 2

Views: 9137

Answers (1)

Indranil Gayen
Indranil Gayen

Reputation: 710

I have access to a Kerberos enabled cluster at my workplace. I am able to connect using following code..

Step 1 : Download latest JDBC driver from Cloudera. I used 2.5.18 in Redhat 6 (x64)

Step 2 : Unzip and use only JDBC 4 connector API.

Step 3 : issue command klist in terminal [I hope you are using linux, if not you may have to setup active directory] and see that there is a ticket active. If the ticket is not present generate it [possibly with the help of admin]

Step 4 : Once you have active ticket [see it as described in Step 3] place all jars unzipped in Step 2 in a folder. [here in my case it is in Drivers/Cloudera-Simba/JDBC4/ inside my R-project directory]

Step 5 : One important thing is that if you have Sentry governing Cloudera Cluster, make sure to login and run following R code from that user who have desired access level.

Step 6 : Run following R code with appropriate host name etc configured in the JDBC Url.

drvH <- JDBC(driverClass = "com.cloudera.hive.jdbc4.HS2Driver", 
             classPath = normalizePath(list.files("Drivers/Cloudera-Simba/JDBC4/", pattern = ".jar$", full.names = T, recursive = T)), 
             identifier.quote="`")

connH <- dbConnect(drvH, "jdbc:hive2://master.rbi.org.in:10000;AuthMech=1;KrbRealm=YOUR_REALM.COM;KrbHostFQDN=master.rbi.org.in;KrbServiceName=hive")

# test it
dbGetQuery(connH, "show databases")

Hope this helps.

You can find more information about Kerberos configuration here.

Upvotes: 4

Related Questions