Solution to Hive Thrift Client Hang without Any Return

3 篇文章 0 订阅

Env:

Cloudera Manager 4.6.1 with CDH4.3

Hadoop 2.0.0-CDH4.3

Hive 0.10.0-CDH4.3

CentOS 6.4 X86_64

 

Hive started successfully:


 

[root@n8 hive]# netstat -anlp | grep 10000
tcp  0  0 0.0.0.0:10000  0.0.0.0:*   LISTEN   21739/java  

 

 

What I want to do: connect to Hive server via Hive Thrift service with below Groovy script:

 

import org.apache.hadoop.hive.service.*;
import org.apache.thrift.protocol.*;
import org.apache.thrift.transport.*;

transport = new TSocket("n8.example.com", 10000);
protocol = new TBinaryProtocol(transport);
client = new HiveClient(protocol);
transport.open();
client.execute("show tables");
client.getClusterStatus();
client.getSchema();
client.fetchOne();
client.fetchAll();

 

 

The dependencies have been placed into Groovy classpath already:

 

    # load required libraries
    load !{groovy.home}/lib/*.jar

    # load user specific libraries
    load !{user.home}/.groovy/lib/*.jar

    # tools.jar for ant tasks
    load ${tools.jar}

    load ${user.home}/dev/hadoop-2.0.0-cdh4.3.0/share/hadoop/common/*.jar
    load ${user.home}/dev/hadoop-2.0.0-cdh4.3.0/share/hadoop/common/lib/*.jar

    load ${user.home}/dev/hadoop-2.0.0-cdh4.3.0/share/hadoop/hdfs/*.jar
    load ${user.home}/dev/hadoop-2.0.0-cdh4.3.0/share/hadoop/hdfs/lib/*.jar

    load ${user.home}/dev/hadoop-2.0.0-cdh4.3.0/share/hadoop/mapreduce/*.jar
    load ${user.home}/dev/hadoop-2.0.0-cdh4.3.0/share/hadoop/mapreduce/lib/*.jar

    load ${user.home}/dev/hadoop-2.0.0-cdh4.3.0/share/hadoop/tools/lib/*.jar

    load ${user.home}/dev/hive-0.10.0-cdh4.3.0/lib/*.jar

 

But when I tried to execute the Groovy script, the executing process was hanged without any return, the connection was reset by the Hive server:

[root@n8 hive]# netstat -anlp | grep 10000
tcp  0    0  0.0.0.0:10000   0.0.0.0:*    LISTEN    21739/java          
tcp  1    0  192.168.1.208:10000  192.168.1.100:50761    CLOSE_WAIT  21739/java 

 

 

Solution: 

Stop the HiveServer2, then execute below command to start another HiveServer2 in which host the Hive installed.

hive --service hiveserver 10000 &

Run above Groovy script then you will find that the script will run successfully.

Or you could keep the first HiveServer2 instance running by choosing another port to run another HiveServer2 on.

hive --service hiveserver 10001 &

 

 

Reason:

By default hive would create the metastore in whichever directory you are starting the thrift server. So when you keep starting the server from various locations it has different metastores which has no reference to your tables which you would have created some where else.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值