2016-02-17 26 views
1

你好,我試圖建立一個nodejs客戶端查詢我的蜂房數據庫使用節儉,但我面臨一個奇怪的問題...我已經生成我的nodejs客戶端API與節儉(thrift -r --gen js:node TCLIService.thrift與TCLIService是節儉文件定義Hive服務),現在我嘗試連接到Hive,但是我的OpenSession正在等待...也許我沒有做正確的調用,但是我沒有在網上找到任何最新的東西(每個節點/節點/蜂巢項目是4或5歲)。你可以看看並告訴我,如果我做錯了嗎?感謝Hive - Thrift - readMessageBegin中缺少的版本,舊客戶端?

TCLIService.thrift:

// 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不是!感謝您的幫助

編輯: 我檢查了我的日誌和NOSASL標識是問題...我已經固定的(我覺得)這個問題現在得到以下錯誤:

客戶:

{ [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它是一個問題?

+0

如果您有任何問題,請提出兩個問題。如果你只有一個,請刪除其餘的。 – JensG

回答

0

我已經做了以下固定我的問題:

用蜂蠟檢查我HiveServer2的協議版本和查詢我HiveServer2(與色調)和檢查HiveServer2日誌(我發現這是HIVE_CLI_SERVICE_PROTOCOL_V7爲0.15蜂房.0)

啓用我HiveServer2 NOSASL認證通過修改蜂房的site.xml

+0

奇怪的是,我沒有在我的日誌中發現任何HIVE_CLI_SERVICE_PROTOCOL_V7,它也不可配置,我使用的是Hive 1.1.0 – tribbloid

0

測試一下環境三個部分,三個都在同一個配置文件(hive-site.xml)默認情況下:

  1. transportMode 檢查hive.server2.transport.mode,您必須在服務和客戶端使用相同的模式。

  2. ssl enable check hive.server2.use.SSL,您可以嘗試關閉以確保與此配置無關。

  3. 權威性 檢查hive.server2.authentication,因爲有身份驗證模式幾種(NONE,NOSASL,KERBEROS,LDAP,自定義),請確保你使用正確的一個。

PS。您可以嘗試通過控制檯連接到您的hs2,並查看服務器是否有任何問題。

相關問題