0

我的 hive 表位于 EMR 集群中。我创建了 SSH 隧道:

ssh -L 8888:localhost:8888 -i atlas-emr-xx.pem hadoop@ec2-aa-bbb-ccc-ddd.us-west-2.compute.amazonaws.com

我可以通过 HUE 从 http://localhost:8888/ 创建和访问配置单元表

现在,我需要从 Python 访问配置单元表,并且代码从我的本地机器执行。

我的代码:

from pyhive import hive
import pandas as pd
conn = hive.Connection(host='localhost', port=8888, username='admin',auth='NOSASL')
df = pd.read_sql("SELECT * FROM atlas_emr.us_disease limit 10", conn)
print(df.head())

我得到的错误:

  File "C:\Users\User\PycharmProjects\Hive\venv\lib\site-packages\thrift\transport\TSocket.py", line 143, in read
    message='TSocket read 0 bytes')
thrift.transport.TTransport.TTransportException: TSocket read 0 bytes

如果我修改代码:

conn = hive.Connection(host='localhost', port=8888, username='admin')

我得到的错误是:

thrift.transport.TTransport.TTransportException: Could not start SASL: b'Error in sasl_client_start (-4) SASL(-4): no mechanism available: Unable to find a callback: 2'

我已遵循如何通过 Python 访问 Hive中提到的所有代码?. 但没有运气

让我知道是否可以访问在 EMR 集群中创建的 Hive。谢谢你。

4

1 回答 1

0

您可以尝试https://docs.aws.amazon.com/athena/latest/ug/connect-to-data-source-hive.html从 EMR 连接到 hive

于 2021-03-29T17:08:31.540 回答