指定端口时出现 Impyla 错误

Impyla error when port is specified

我正在使用 impyla 0.9.0,如果我在连接中指定端口

conn = impala.dbapi.connect(host='n1', port=21000)

我会得到以下错误

Traceback (most recent call last):
  File "./myquery.py", line 78, in <module>
    main(len(sys.argv), sys.argv)
  File "./myquery.py", line 58, in main
    cur = conn.cursor()
  File "/usr/lib/python2.6/site-packages/impala/dbapi/hiveserver2.py", line 55, in cursor
    rpc.open_session(self.service, user, configuration))
  File "/usr/lib/python2.6/site-packages/impala/_rpc/hiveserver2.py", line 132, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/impala/_rpc/hiveserver2.py", line 214, in open_session
    resp = service.OpenSession(req)
  File "/usr/lib/python2.6/site-packages/impala/_thrift_gen/TCLIService/TCLIService.py", line 175, in OpenSession
    return self.recv_OpenSession()
  File "/usr/lib/python2.6/site-packages/impala/_thrift_gen/TCLIService/TCLIService.py", line 191, in recv_OpenSession
    raise x
thrift.Thrift.TApplicationException: Invalid method name: 'OpenSession'

但它是一个有效的端口。

impala-shell -i n1:21000
Starting Impala Shell without Kerberos authentication
Connected to n1:21000
Server version: impalad version 2.1.1-cdh5 RELEASE (build 7901877736e29716147c4804b0841afc4ebc9037)
Welcome to the Impala shell. Press TAB twice to see a list of available commands.

Copyright (c) 2012 Cloudera, Inc. All rights reserved.

(Shell build version: Impala Shell v2.1.1-cdh5 (7901877) built on Tue Jan 27 16:23:42 PST 2015)
[n1:21000] >

一旦我删除端口

conn = impala.dbapi.connect(host='n1')

又能用了。

Impyla 正在尝试使用 HiveServer2 协议连接到 Impala,因此您应该使用端口 21050。端口 21000 用于 Beeswax 协议(Impala shell 使用).