2017-06-13 109 views
0

我试图设置一个配置单元连接,如下所述:How to Access Hive via Python?使用配置单元。与python 3.5.2(安装在cloudera Linux BDA上)连接,但SASL包似乎会导致问题。我在论坛上看到,SASL仅与2.7 python兼容。是对的吗?我错过/做错了什么?Pyhive,SASL和Python 3.5

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) 

回答

0

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

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

添加以下内容:

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

要了Cloudera管理器中的以下配置单元的配置参数:

HiveServer2高级配置片段(安全阀)的蜂房的site.xml 蜂巢客户端高级配置片段(安全阀)hive-site.xml必需,以便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() 

工作没有问题/ er ROR。

最佳, 汤姆

+0

我的hive.server2.authentication设置为CUSTOM,所以我需要做什么?如何? –

+0

以下pyhive代码:'raise NotImplementedError( “Only only NONE,NOSASL,LDAP,KERBEROS” “authentication is supported,got {}”。format(auth))'实际上我不知道。对不起,没有帮助 –

0

检查您是否已经安装了所有的依赖:

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

(在Windows假设您选择)

+0

我会检查但无论如何,它是在Linux BDA,谢谢! –

+0

更多信息:安装gcc和cyrus-sasl-devel。 python-devel以及2.6版本,因为它是随操作系统提供的版本,用于BDA的cloudera套件。我们并没有使用Python系统,而是使用了由Anaconda提供的系统。 –

+0

python 3.5.2蟒蛇自定义(64位) [GCC 4.4.7 20120313(红帽4.4.7-1)] –