Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用PHP连接HiveServer2_Php_Hadoop_Hive - Fatal编程技术网

使用PHP连接HiveServer2

使用PHP连接HiveServer2,php,hadoop,hive,Php,Hadoop,Hive,我想使用PHP连接HiveServer2,为此我发现唯一的选项是可用的 但它仅适用于配置单元服务器1,不适用于配置单元服务器2。在找到更多信息后,这是因为thrift服务器希望在您打开传输连接时通过SASL进行身份验证。Hive Server 2默认使用SASL-不幸的是,PHP缺少一个版本的TSaslClientTransport(用作另一个TTTransport对象的包装器),当您打开传输连接时,该版本可以处理SASL协商 是否有人成功地使用php连接了hive server2。 <?

我想使用PHP连接HiveServer2,为此我发现唯一的选项是可用的

但它仅适用于配置单元服务器1,不适用于配置单元服务器2。在找到更多信息后,这是因为thrift服务器希望在您打开传输连接时通过SASL进行身份验证。Hive Server 2默认使用SASL-不幸的是,PHP缺少一个版本的TSaslClientTransport(用作另一个TTTransport对象的包装器),当您打开传输连接时,该版本可以处理SASL协商

是否有人成功地使用php连接了hive server2。


<?php

    // set THRIFT_ROOT to php directory of the hive distribution
    $GLOBALS['THRIFT_ROOT'] = '/lib/php/';
    // load the required files for connecting to Hive
    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';
    // Set up the transport/protocol/client
    $transport = new TSocket('localhost', 10000);
    $protocol = new TBinaryProtocol($transport);
    $client = new ThriftHiveClient($protocol);
    $transport->open();

    // run queries, metadata calls etc
    $client->execute('SELECT * from src');
    var_dump($client->fetchAll());
    $transport->close();

?>
以下是apache网站上的文档:

您能否找到一种使用PHP连接到Hive server2的方法。我也有同样的问题,找不到任何文档或工作示例。如果找到解决方案,请告诉我。此代码示例与hive server2不兼容