Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I was trying to connect to hive using RHive but I'm getting a connection refused error.

library(RHive)
Loading required package: rJava
Loading required package: Rserve
This is RHive 0.0-7. For overview type a?RHivea.
HIVE_HOME=/home/surya/hive-0.8.1
call rhive.init() because HIVE_HOME is set.
> rhive.connect()
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  :
  org.apache.thrift.transport.TTransportException: java.net.ConnectException: Connection refused
NULL
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
333 views
Welcome To Ask or Share your Answers For Others

1 Answer

open your terminal and follow below steps.

  1. first start your hadoop hdfs

    cd /usr/local/hadoop && /bin/start-all.sh

  2. start your hive serve

    cd /usr/local/hive/ && bin/hive --service hiveserver

it will start process and don't close your terminal

Now open your R/Rstudio and run below statements

library(Rserve) #loading R server package
Rserve(args=”—no-save”)
Sys.setenv(HADOOP_HOME=”/usr/local/hadoop”)
Sys.setenv(HIVE_HOME=”/usr/local/hive”)
library(RHive)
rhive.connect()
rhive.env()
rhive.init()
x=1:10
y=x**2
xy=data.frame(x,y)
rhive.write.tables(xy)
rhive.list.tables()

now you can see a table of xy on hive


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...