python - 使用 Thrift 在 Python 脚本中运行 Hive-Query 时出现 `Connection Refused`

标签 python hadoop mapreduce hive thrift

全部,

我正在尝试使用 Python 的 Thrift 库在 Python 脚本中运行配置单元查询。 我能够运行不执行 M/R 的查询,例如 create tableselect * from table 等。 但是当我执行执行 M/R 作业的查询时(如 select * from table where...),我得到以下异常。

starting hive server...

Hive history file=/tmp/root/hive_job_log_root_201212171354_275968533.txt
Total MapReduce jobs = 1
Launching Job 1 out of 1
Number of reduce tasks determined at compile time: 1
In order to change the average load for a reducer (in bytes):
  set hive.exec.reducers.bytes.per.reducer=<number>
In order to limit the maximum number of reducers:
  set hive.exec.reducers.max=<number>
In order to set a constant number of reducers:
  set mapred.reduce.tasks=<number>
java.net.ConnectException: Call to sp-rhel6-01/172.22.193.79:54311 failed on connection exception: java.net.ConnectException: Connection refused

Job Submission failed with exception 'java.net.ConnectException(Call to sp-rhel6-01/172.22.193.79:54311 failed on connection exception: java.net.ConnectException: Connection refused)'
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.MapRedTask

我有一个多节点 hadoop 集群,我的配置单元安装在名称节点中,我也在同一个名称节点上运行 python 脚本。

python脚本是

from hive_service import ThriftHive
from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol

transport = TSocket.TSocket('172.22.193.79', 10000)
transport = TTransport.TBufferedTransport(transport)
protocol = TBinaryProtocol.TBinaryProtocol(transport)

client = ThriftHive.Client(protocol)
transport.open()

client.execute("select count(*) from example ")
print client.fetchAll();
transport.close()

谁能帮我弄明白哪里出了问题?

-苏珊特

最佳答案

我在完成 SELECT 查询时遇到了问题,尽管我可以完成 SHOWDESCRIBE 查询。我解决这个问题的方法是重新启动集群上的服务。 我正在使用 Cloudera 来管理我的集群,所以我运行的命令是 $ sudo/etc/init.d/cloudera-scm-agent hard_restart。我没有花太多时间调试,但我猜是 NN 或 JT 崩溃了。有趣的是我仍然可以完成对元数据的查询。我最好的猜测是查询直接进入 Metastore 而不必触及 HDFS。不过,我需要有人确认这一点。

关于python - 使用 Thrift 在 Python 脚本中运行 Hive-Query 时出现 `Connection Refused`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13923159/

相关文章:

python - 如何避免Python中除零错误

hadoop - HIVE如何根据某些条件更新现有数据,如果不存在则插入新数据

java - 出于某种奇怪的原因在 map reduce 程序中获取 NumberFormatException

python - 使用 python 3 通过 SSH(通过跳转主机)连接到 MySQL 数据库

python - GDB打印STL数据

python - pywinauto 中的 print_control_identifiers() 错误

在 Windows 10 上安装 Apache hadoop

hadoop - 如何抑制 hadoop fs 命令的信息消息

hadoop - 一个包含 HDFS 和 MapReduce 的文件数据库

google-app-engine - Appengine 上的 Map-Reduce 状态?