【问题标题】:TSocket: Could not connect to server (Connection timed out [110])TSocket:无法连接到服务器(连接超时 [110])
【发布时间】:2023-05-04 14:27:02
【问题描述】:

跟随这篇文章

http://nousefor.net/55/2011/12/php/hbase-and-hive-thrift-php-client/

我下载了 HBase 和 Thrift php 客户端包并将它们放在我的 ubuntu 机器上的 var/www/thrift/ 目录中,并编写了这个简单的客户端代码来打开连接并显示数据库中的表。但服务器不断恢复并显示错误消息“连接超时 [110]”。有任何想法吗..??此外,代码在使用$transport = new TSocket('localhost', 10001); 的服务器(Amazon EC2)上运行时也能正常执行

<?php

require_once('thrift/src/Thrift.php' );
require_once('thrift/src/transport/TSocket.php' );
require_once('thrift/src/transport/TBufferedTransport.php' );
require_once('thrift/src/protocol/TBinaryProtocol.php' );
require_once ('thrift/ThriftHive.php');

//open connection
$transport = new TSocket('107.xx.xx.101', 10001);
$protocol = new TBinaryProtocol($transport);
$client = new ThriftHiveClient($protocol);

try{
    $transport->open();
}
catch(Exception $ex)
{
    echo $ex->getMessage();
}

//show tables
$client->execute('SHOW TABLES');
$tables = $client->fetchAll();
foreach ($tables as $name){
echo( " found: {$name}\n" );
}


?>

【问题讨论】:

  • 错误信息的意思是:(1)Thrift没有运行(或)(2)端口错误。你能找出问题所在吗?
  • 不,我无法找出问题所在,但我可以使用 JDBC 完成工作。但是我仍然对这段代码的失败感到困惑。
  • 我明白了,您的服务器在 Amazon EC2 上。确保您的安全组允许公众访问该端口(10001?)。

标签: apache hadoop hbase hive thrift


【解决方案1】:

我认为您没有指向安装 Hive 主服务器的正确主机。请检查您的Hive Metastore host ip 地址在哪里。

可能对你有帮助,谢谢。

【讨论】: