在运行此代码时,卡在 $client->execute('SHOW DATABASES');
行。库位于正确的目录中,但不知何故我们无法进行查询
<?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('localhost', 10001);
$transport->setSendTimeout(30 * 1000);
$transport->setRecvTimeout(30 * 1000);
$client = new ThriftHiveClientEx(new TBinaryProtocol($transport));
$client->open();
print('open');
//shell_exec('hive');
$client->execute('SHOW DATABASES');
print('database');
var_dump($client->fetchAll());
print('dump');
$client->close();
print('close');
最佳答案
通过添加一行我们的 hive-site.xml 关闭 SASL 身份验证后,连接将成功。
关于php - 使用 php thrift 的 Hive 查询不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38301983/