简体   繁体   中英

php hiveserver 2 issues

I want to connect to hiveserver2 from a php client. However, I'm getting a blank page (I'm supposed to see a list of tables in hive). I adapted code from https://github.com/garamon/php-thrift-hive-client . Initially, I was getting this error TSocket: timed out reading 4 bytes from host . After implementing a patch as suggested here https://stackoverflow.com/a/19199938/4379550 . The error disappeared but I'm getting nothing. My code is as below

<?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" );
}
?>

The error message on the server retrieved from cloudera manager is shown below:

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

I will appreciate any help. Many thanks in advance.

For those facing the same problem, I solved it by setting the hive.server2.authentication property to NOSASL as previously answered here . The reason I couldn't get it done earlier is because I was changing this property by going to the file on the server and that did not work, I guess because I'm using cloudera distribution. What worked was setting this property in cloudera manager as described in their documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM