hive-thrift-readmessagebegin中缺少版本,旧客户端?

4dbbbstv  于 2021-06-02  发布在  Hadoop
关注(0)|答案(2)|浏览(498)

你好,我试图建立一个nodejs客户端查询我的Hive数据库使用节俭,但我面临一个奇怪的问题。。。我已经用thrift生成了nodejs客户端api( thrift -r --gen js:node TCLIService.thrift tcliservice是定义配置单元服务的旧文件),现在我尝试连接到配置单元,但是我的opensession挂起了。。。也许我做得不对,但我在网上找不到任何最新的东西(每个节俭/节点/Hive项目都有4到5年的历史)。你能看一下告诉我我做错了吗?谢谢
节俭:

// OpenSession()
//
// Open a session (connection) on the server against
// which operations may be executed.
struct TOpenSessionReq {
    // The version of the HiveServer2 protocol that the client is using.
    1: required TProtocolVersion client_protocol = TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V8

    // Username and password for authentication.
    // Depending on the authentication scheme being used,
    // this information may instead be provided by a lower
    // protocol layer, in which case these fields may be
    // left unset.
    2: optional string username
    3: optional string password

    // Configuration overlay which is applied when the session is
    // first created.
    4: optional map<string, string> configuration
}

service TCLIService {
    TOpenSessionResp OpenSession(1:TOpenSessionReq req);
}

nodejs代码:var sessionhandle=“”;

function openSession(config) {
    openSessReq = new ttypes.TOpenSessionReq();
    openSessReq.client_protocol = ttypes.TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V8;
    openSessReq.username = config.hiveUser;
    openSessReq.password = config.hivePassword;
    console.log("openSessReq = " + JSON.stringify(openSessReq));
    console.log("Before OpenSession : sessionHandle = " + sessionHandle);
    sessionHandle = client.OpenSession(openSessReq, function (err, result){
        console.log('handler fired ... ');
        if (err) {
            console.error("error : " + err);
        } else {
            console.log("result : " + result);
        }
    });
    console.log("After OpenSession : sessionHandle = " + sessionHandle);
}

connection.on('error', function(err) {
    /*Error detected, print the error*/
    console.error(err);
    /*Close the program with error code*/
    process.exit(1)
});

console.log('Error handler registered ...')

connection.on('connect', function(){
    console.log('Connected ...');
    /*Init session*/
    console.log(client);
    openSession(config);
}

我的输出如下:

CreateConnection DONE ...
Error handler registered ...
Connect handler registered ...
Connected ...
{ output:
   TBufferedTransport {
     defaultReadBufferSize: 1024,
     writeBufferSize: 512,
     inBuf: <Buffer e8 19 2b 03 00 00 00 00 b0 1a 2b 03 00 00 00 00 e8 18 2b 03 00 00 00 00 f0 18 2b 03 00 00 00 00 b0 19 2b 03 00 00 00 00 78 1a 2b 03 00 00 00 00 70 1d ... >,
     readCursor: 0,
     writeCursor: 0,
     outBuffers: [],
     outCount: 0,
     onFlush: [Function],
     client: [Circular] },
  pClass: [Function: TBinaryProtocol],
  _seqid: 0,
  _reqs: {} }
openSessReq = {"client_protocol":7,"username":"root","password":"root","configuration":null}
Before OpenSession : sessionHandle =
After OpenSession : sessionHandle = undefined
^C

脚本正在无限期运行。。。如果我更改端口或关闭hiveserver,我将面临一个错误,因此连接可以工作,但我无法找出opensession不工作的原因!谢谢你的帮助
编辑:我已经检查了我的日志和NOSSL的身份是问题所在。。。我已修复(我认为)此问题,现在出现以下错误:
客户:

{ [Error: write EPIPE]
 code: 'EPIPE',
 errno: 'EPIPE',
 syscall: 'write',
 address: undefined }

服务器:

2016-02-17 13:36:37,152 ERROR org.apache.thrift.server.TThreadPoolServer: [HiveServer2-Handler-Pool: Thread-24]: Thrift error occurred during processing of message.
    org.apache.thrift.protocol.TProtocolException: Missing version in readMessageBegin, old client?
        at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:228)
        at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:27)
        at org.apache.hive.service.auth.TSetIpAddressProcessor.process(TSetIpAddressProcessor.java:56)
        at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:285)
        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)

我读到这个问题一定是因为使用了错误的协议层。。。我用的是tbinaryprotocol有问题吗?

guz6ccqo

guz6ccqo1#

尝试检查环境的三部分,所有三部分都在同一配置文件中( hive-site.xml )默认情况下:
传输模式检查 hive.server2.transport.mode ,您必须在serve和client中使用相同的模式。
ssl启用检查 hive.server2.use.SSL ,您可以尝试关闭以确保与此配置无关。
身份验证检查 hive.server2.authentication ,因为有几种身份验证模式(none、nosal、kerberos、ldap、custom),所以请确保使用正确的身份验证模式。
另外,您可以尝试通过控制台连接到您的hs2,看看服务器是否有任何问题。

krugob8w

krugob8w2#

我已通过执行以下操作解决了问题:
使用beewax检查我的hiveserver2的协议版本,查询我的hiveserver2(带有hue)并检查hiveserver2日志(我发现它是hive 0.15.0的hive\u cli\u service\u protocol\u v7)
通过修改hive-site.xml在我的hiveserver2上启用nosal身份验证

相关问题