【问题标题】:Pyhive, SASL and Python 3.5Pyhive、SASL 和 Python 3.5
【发布时间】:2017-11-15 07:24:33
【问题描述】:

我尝试按照此处所述设置配置单元连接:How to Access Hive via Python? 使用配置单元。与 python 3.5.2 的连接(安装在 cloudera Linux BDA 上)但 SASL 包似乎会导致问题。我在一个论坛上看到,SASL 只兼容 2.7 python。那正确吗?我错过了什么/做错了什么?

from pyhive import hive
conn = hive.Connection(host="myserver", port=10000)
import pandas as pd

错误信息

TTransportException Traceback (most recent call last)
in ()
1 from pyhive import hive
2 #conn = hive.Connection(host="myserver", port=10000)
----> 3 conn = hive.Connection(host="myserver")
4 import pandas as pd

/opt/anaconda3/lib/python3.5/site-packages/pyhive/hive.py in init(self, host, port, username, database, auth, configuration)
102
103 try:
--> 104 self._transport.open()
105 open_session_req = ttypes.TOpenSessionReq(
106 client_protocol=protocol_version,

/opt/anaconda3/lib/python3.5/site-packages/thrift_sasl/init.py in open(self)
70 if not ret:
71 raise TTransportException(type=TTransportException.NOT_OPEN,
---> **72 message=("Could not start SASL: %s" % self.sasl.getError()))**
73
74 # Send initial response

TTransportException: TTransportException(message="Could not start SASL: b'Error in sasl_client_start (-4) SASL(-4): no mechanism available: No worthy mechs found'", type=1)

【问题讨论】:

    标签: python hadoop hive connection sasl


    【解决方案1】:

    我们(我应该说,IT 团队)找到了解决方案

    升级python包thrift(到0.10.0版)和PyHive(到0.3.0版)不知道为什么我们使用的版本不是最新的。

    添加了以下内容:

    <property>
    <name>hive.server2.authentication</name>
    <value>NOSASL</value>
    </property>
    

    到 Cloudera Manager 中的以下 Hive 配置参数:

    hive-site.xml 的 HiveServer2 高级配置片段(安全阀) hive-site.xml 的 Hive 客户端高级配置片段(安全阀)是 HUE 工作所必需的

    from pyhive import hive
    conn = hive.Connection(host="myserver", auth='NOSASL')
    import pandas as pd
    import sys
    
    df = pd.read_sql("SELECT * FROM my_table", conn) 
    print(sys.getsizeof(df))
    df.head()
    

    工作没有问题/错误。

    最好, 汤姆

    【讨论】:

    • 我的 hive.server2.authentication 设置为 CUSTOM,所以我需要做什么??以及如何?
    • 遵循 pyhive 代码:raise NotImplementedError( "Only NONE, NOSASL, LDAP, KERBEROS " "authentication are supported, got {}".format(auth)) 所以实际上我不知道。抱歉,没有帮助
    【解决方案2】:

    检查是否安装了所有依赖项:

    gcc-c++
    python-devel.x86_64
    cyrus-sasl-devel.x86_64
    

    (假设你在 Windows 上)

    【讨论】:

    • 更多信息:gcc 和 cyrus-sasl-devel 已安装。 python-devel 也是如此(但 2.6 版本是操作系统附带的版本,用于 BDA 的 cloudera 套件)。不过,我们没有使用 Python 系统,而是使用 Anaconda 提供的系统。
    • python 3.5.2 Anaconda 自定义(64 位)[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 1970-01-01
    • 1970-01-01
    • 2022-01-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多