指定端口时出现Impyla错误

时间:2015-02-28 20:33:27

标签: python cloudera-cdh impala

如果我在连接

中指定端口,我使用的是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')

再次有效。

1 个答案:

答案 0 :(得分:8)

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