我想从php客户端连接到hiveserver2。但是,我得到一个空白页面(我应该在蜂巢中看到一个表格列表)。我修改了代码
https://github.com/garamon/php-thrift-hive-client。最初,我收到了这个错误
TSocket: timed out reading 4 bytes from host
。按照此处https://stackoverflow.com/a/19199938/4379550建议实施补丁后。错误消失但我什么都没得到。我的代码如下
<?php
$GLOBALS['THRIFT_ROOT'] = dirname(__FILE__) . '/lib';
require_once $GLOBALS['THRIFT_ROOT'] . '/packages/hive_service/ThriftHive.php';
require_once $GLOBALS['THRIFT_ROOT'] . '/transport/TSocket.php';
require_once $GLOBALS['THRIFT_ROOT'] . '/protocol/TBinaryProtocol.php';
require_once dirname(__FILE__) . '/ThriftHiveClientEx.php';
$transport = new TSocket('hadoop-gate.iis.u-tokyo.ac.jp', 10000);
$transport->setSendTimeout(600 * 100);
$transport->setRecvTimeout(600 * 100);
$client = new ThriftHiveClientEx(new TBinaryProtocol($transport));
$client->open();
//show tables
$client->execute('SHOW TABLES');
print_r($client);
$tables = $client->fetchAll();
print_r($tables);
foreach ($tables as $name){
echo( " found: {$name}\n" );
}
?>
从cloudera manager检索到的服务器上的错误消息如下所示:
6:49:48.859 PM ERROR org.apache.thrift.server.TThreadPoolServer
Error occurred during processing of message.
java.lang.RuntimeException: org.apache.thrift.transport.TTransportException: Invalid status -128
at org.apache.thrift.transport.TSaslServerTransport$Factory.getTransport(TSaslServerTransport.java:219)
at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:227)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.thrift.transport.TTransportException: Invalid status -128
at org.apache.thrift.transport.TSaslTransport.sendAndThrowMessage(TSaslTransport.java:230)
at org.apache.thrift.transport.TSaslTransport.receiveSaslMessage(TSaslTransport.java:184)
at org.apache.thrift.transport.TSaslServerTransport.handleSaslStartMessage(TSaslServerTransport.java:125)
at org.apache.thrift.transport.TSaslTransport.open(TSaslTransport.java:262)
at org.apache.thrift.transport.TSaslServerTransport.open(TSaslServerTransport.java:41)
at org.apache.thrift.transport.TSaslServerTransport$Factory.getTransport(TSaslServerTransport.java:216)
... 4 more
我将不胜感激任何帮助。非常感谢提前。
答案 0 :(得分:1)
对于那些面临同样问题的人,我通过设置hive.server2.authentication
解决了这个问题
之前已回复here的NOSASL
财产。我之前无法完成它的原因是因为我正在改变这个属性
在服务器上的文件并没有用,我猜是因为我正在使用cloudera发行版。有用的是在cloudera manager中设置此属性,如documentation中所述。