Community Articles
Find and share helpful community-sourced technical articles.
Labels (1)


  • Access Hive through R shell with Rhive
  • Authentication mechanism: Kerberos


  • Have a HDP cluster up and running
  • Have configured and installed R
  • Cluster is configured on CentOS7
  • Need to have openssl-devel installed on the server where R is installed
  • If using openjdk, ensure that the JAVA_HOME is set to the path where javac is available


  • Download Rserve
  • Use R to install Rserve
R CMD INSTALL Rserve_1.8-5.tar.gz
  • Download rhive library
git clone
  • Set the appropriate path for HIVE_HOME and HADOOP_HOME
export HADOOP_HOME=/usr/hdp/; export HIVE_HOME=/usr/hdp/
  • Change directory to RHive
cd RHive
  • Use ant to build
ant build
  • Use R to build RHive, this will build a file within the same directory
R CMD build RHive
  • Use the newly created file name to install RHive library
R CMD INSTALL RHive_2.0-0.10.tar.gz


  • Launch R using "R" at the unix prompt
  • Load RHive library
> library(RHive)
Loading required package: rJava
Loading required package: Rserve
  • Use the connection string in this format
> rhive.connect(host=";principal=hive/;AuthMech=1;;KrbServiceName=hive;KrbRealm=HDP.COM", defaultFS="hdfs://", hiveServer2=TRUE,updateJar=FALSE)

2016-11-09 22:30:00,425 WARN  [main] util.NativeCodeLoader (<clinit>(62)) - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
2016-11-09 22:30:01,361 WARN  [main] shortcircuit.DomainSocketFactory (<init>(117)) - The short-circuit local reads feature cannot be used because libhadoop cannot be loaded.
2016-11-09 22:30:01,853 INFO  [Thread-7] jdbc.Utils ( - Supplied authorities:
2016-11-09 22:30:01,853 INFO  [Thread-7] jdbc.Utils ( - Resolved authority:

  • Querying a table
> rhive.query("SELECT * FROM default.test")
  test.col1 test.col2
1         1         1
2         2         2
3         3         3
4         4         4

Enjoy !!

Expert Contributor

Where are steps to configure R-server for Kerberos? Does it not need any kerberos related settings? No kinit etc..?

I noticed that the connect string has kerberos related variables though. Is it really good enough? Please confirm.

rhive.connect(host=";principal=hive/;AuthMech=1;;KrbServiceName=hive;KrbRealm=HDP.COM", defaultFS="hdfs://", hiveServer2=TRUE,updateJar=FALSE))
Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.
Version history
Last update:
‎11-10-2016 02:35 AM
Updated by:
Top Kudoed Authors