【问题标题】:impala.error.HiveServer2Error: Failed after retrying 3 timesimpala.error.HiveServer2Error:重试 3 次后失败
【发布时间】:2021-10-28 06:29:54
【问题描述】:

我使用 impyla 和 ibis 连接 hive 服务器,但出现错误。 我尝试了以下代码:

from impala.dbapi import connect
impcur = connect(host="kudu3", port=10000, database="yingda_test", password=None, user='admin', kerberos_service_name='None').cursor()

新的错误出来了:

Traceback (most recent call last):
  File "/Users/edy/src/PythonProjects/dt-center-algorithm/test/1.py", line 4, in <module>
    impcur = connect(host="kudu3", port=10000, database="yingda_test", password=None, user='admin', kerberos_service_name='None').cursor()
  File "/usr/local/conda3/envs/py37/lib/python3.7/site-packages/impala/hiveserver2.py", line 129, in cursor
    session = self.service.open_session(user, configuration)
  File "/usr/local/conda3/envs/py37/lib/python3.7/site-packages/impala/hiveserver2.py", line 1187, in open_session
    resp = self._rpc('OpenSession', req, True)
  File "/usr/local/conda3/envs/py37/lib/python3.7/site-packages/impala/hiveserver2.py", line 1080, in _rpc
    response = self._execute(func_name, request, retry_on_http_error)
  File "/usr/local/conda3/envs/py37/lib/python3.7/site-packages/impala/hiveserver2.py", line 1142, in _execute
    .format(self.retries))
impala.error.HiveServer2Error: Failed after retrying 3 times

节俭 0.15.0 节俭-sasl 0.4.3 thriftpy2 0.4.14 纯sasl 0.6.2 萨斯勒 0.2.1 节俭-sasl 0.4.3 宜必思框架 2.0.0 impyla 0.17.0 python 版本:3.7.12 with anaconda

我已经尝试过 ibis-1.3.0 和 2.0 版本。你们可以给一些建议吗?很多东西

【问题讨论】:

    标签: python-3.x hive impyla ibis


    【解决方案1】:

    我也遇到过这个问题。

    我的代码是:

    from impala.dbapi import connect
    import psycopg2
    
    conn_hive = connect(host="xxx.xxx.xxx.xxx", port=xxx, user='admin', 
                        password='password', database='xxx', auth_mechanism="PLAIN", timeout=6000)
    hive_cursor = conn_hive.cursor()
    hive_cursor.execute(query_sql)
    data_list = hive_cursor.fetchall()
    ...get data...
    hive_cursor.close()
    conn_hive.close()
    

    经过我和同事的尝试,发现手动重新连接hive会成功。

    意思是如果你想从同一个hive数据库中获取不同的数据,你最好关闭连接并通过以下代码手动重新连接hive:

    conn_hive = connect(host="xxx.xxx.xxx.xxx", port=xxx, user='admin', 
                        password='password', database='xxx', auth_mechanism="PLAIN", timeout=6000)
    hive_cursor = conn_hive.cursor()
    hive_cursor.execute(query_sql)
    data_list = hive_cursor.fetchall()
    ...get data1...
    hive_cursor.close()
    conn_hive.close()
    
    conn_hive = connect(host="xxx.xxx.xxx.xxx", port=xxx, user='admin', 
                        password='password', database='xxx', auth_mechanism="PLAIN", timeout=6000)
    hive_cursor = conn_hive.cursor()
    hive_cursor.execute(query_sql)
    data_list = hive_cursor.fetchall()
    ...get data2...
    hive_cursor.close()
    conn_hive.close()
    

    最后同事告诉我,最近黑斑羚出现了问题。

    【讨论】:

      猜你喜欢
      • 2013-12-12
      • 2015-10-18
      • 2020-07-03
      • 2015-09-05
      • 1970-01-01
      • 1970-01-01
      • 2015-10-31
      • 2012-08-14
      • 1970-01-01
      相关资源
      最近更新 更多