Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

PyHive don't connect - Kerberized Cluster

PyHive don't connect - Kerberized Cluster

New Contributor

Hi my name is Sardano, I’m from Brazil.

Please can you help me?

I tring to connect in our Hiveserver2 (Hortownworks Kerberized Cluster), but until now without success, geting the message:

	Python 2.7.15
|Anaconda, Inc.| (default, Dec 14 2018, 19:04:19)
	[GCC 7.3.0] on
linux2
	Type
"help", "copyright", "credits" or
"license" for more information.
	>>> from
pyhive import hive
	>>>
c=hive.Connection(host='clusterKerberizado', port='2181', auth='KERBEROS',
kerberos_service_name='krbtgt',
configuration={'serviceDiscoveryMode':'zooKeeper','zooKeeperNamespace':'hiveserver2'})
	Traceback (most
recent call last):
	File , line 1, in
	File
"/home/xxxx/miniconda/lib/python2.7/site-packages/pyhive/hive.py",
line 192, in __init__
	self._transport.open()
	File "/home/xxxx/miniconda/lib/python2.7/site-packages/thrift_sasl/__init__.py",
line 79, in open
	message=("Could not start SASL:
%s" % self.sasl.getError()))
	thrift.transport.TTransport.TTransportException:
Could not start SASL: Error in sasl_client_start (-4) SASL(-4): no mechanism
available: No worthy mechs found

These are my configurations:

$ rpm -qa | grep -i "cyrus"

cyrus-sasl-gssapi-2.1.26-21.el7.x86_64

cyrus-sasl-plain-2.1.26-21.el7.x86_64

cyrus-sasl-lib-2.1.26-21.el7.x86_64

$ conda list

# packages in environment at /home/sardano/miniconda:

#

# NameVersionBuildChannel

asn1crypto0.24.0py27_0

atk1.28.00ska

bcrypt3.1.6py27h7b6447c_0

bumpversion0.5.3py_1001conda-forge

bzip21.0.6h14c3975_5

ca-certificates2019.1.230

cairo1.8.80ska

certifi2018.11.29py27_0

cffi1.11.5py27he75722e_1

chardet3.0.4py27_1

click7.0py27_0

conda4.6.2py27_0

conda-env2.6.01

cryptography2.4.2py27h1ba5d50_0

cx_oracle7.0.0py27h7b6447c_0

cyrus-sasl2.1.26h82bf5a1_4

django1.11.10py27hd476221_0

django-cachalot2.1.0py_0conda-forge

django-environ0.4.5py_1conda-forge

django-guardian1.5.0py_0conda-forge

djangorestframework3.9.1py_0conda-forge

enum341.1.6py27_1

expat2.1.0py27_0ska

flask1.0.2py27_1

fontconfig2.7.30ska

funcsigs1.0.2py_3conda-forge

future0.17.1py27_0

futures3.2.0py27_0

gevent1.4.0py27h7b6447c_0

glib2.22.20ska

greenlet0.4.15py27h7b6447c_0

gtk-plus2.18.30ska

happybase1.1.0py27_2conda-forge

hdfs30.3.0py27_1

icu58.2h9c2bf20_1

idna2.8py27_0

ipaddress1.0.22py27_0

itsdangerous1.1.0py27_0

jinja22.10py27_0

kazoo2.2.1py27_0XXXX

krb51.16.1h173b8e3_7

libboost1.67.0h46d08c1_4

libcurl7.63.0h20c2e04_1000

libdb6.1.26he6710b0_0

libedit3.1.20170329h6b74fdf_2

libffi3.2.1hd88cf55_4

libgcc-ng8.2.0hdf63c60_1

libgcrypt1.8.4h7b6447c_0

libgpg-error1.32hf484d3e_0

libgsasl1.8.0h7b6447c_3

libhdfs32.3.0h2fca0e8_1

libntlm1.4h14c3975_2

libpq11.1h20c2e04_0

libprotobuf3.6.0hdbcaa40_0

libsodium1.0.16h1bed415_0

libssh21.8.0h1ba5d50_4

libstdcxx-ng8.2.0hdf63c60_1

libuuid1.0.3h1bed415_2

libxml22.9.9he19cac6_0

markupsafe1.1.0py27h7b6447c_0

mock2.0.0py27_1000conda-forge

mysql-connector-c6.1.11h597af5e_0

mysql-connector-python8.0.13py27h9c95fcb_0

ncurses6.1he6710b0_1

openssl1.1.1ah7b6447c_0

pango1.26.00ska

paramiko2.4.2py27_0

pbr5.1.2py_0conda-forge

pip18.1py27_0

pixman0.16.20ska

ply3.11py_1conda-forge

protobuf3.6.0py27hf484d3e_0

psycopg22.7.6.1py27h1ba5d50_0

pyasn1 0.4.5py_0

pycairo1.8.80ska

pycosat0.6.3py27h14c3975_0

pycparser2.19py27_0

pydoop1.2.0pypi_0pypi

pygobject2.20.00ska

pygtk2.16.00ska

pyhive0.6.1py27_0

pynacl1.3.0py27h7b6447c_0

pyopenssl18.0.0py27_0

pysocks1.6.8py27_0

python2.7.15h9bab390_6

pytz2018.9py27_0

readline7.0h7b6447c_5

requests2.21.0py27_0

ruamel_yaml0.15.46py27h14c3975_0

sasl0.2.1py27h779454e_1

setuptools40.6.3py27_0

simplejson3.16.0py27h14c3975_0

six1.12.0py27_0

sqlalchemy1.2.16py27h7b6447c_0

sqlite3.26.0h7b6447c_0

thrift0.11.0py27hf484d3e_0

thrift_sasl0.3.0py27_1

thriftpy0.3.9py27h14c3975_1001conda-forge

tk8.6.8hbc83047_0

urllib31.24.1py27_0

werkzeug0.14.1py27_0

wheel0.32.3py27_0

xz5.2.4h14c3975_4

yaml0.1.7had09818_2

zlib1.2.11h7b6447c_3

$ klist -e

Ticket cache: FILE:/tmp/krb5cc_ xxxx

Default principal: xxxx @ABCD.BR

Valid startingExpiresService principal

02/15/2019 08:06:0102/15/2019 18:06:01krbtgt/ ABCD.BR@ ABC.BR

renew until 02/16/2019 08:05:53, Etype (skey, tkt): arcfour-hmac, arcfour-hmac

--------------------------------------------------------------------

#!/usr/bin/env python

# Studying the PyHive code, I've isolated these small simplified snippy of code to reproduce the problem:

import thrift.transport.TSocket
import thrift.transport.TTransport
import sasl

host = ""
kerberos_service_name = ""

def sasl_factory():
sasl_client = sasl.Client()
sasl_client.setAttr('host', host)
sasl_client.setAttr('service', kerberos_service_name)
sasl_client.init()
return sasl_client

# Copy of PyHive code (simplifyed):
def pyhive_simplified(port, sasl_auth):
print "PyHive Simplified code ----------------------------------------------------"
socket = thrift.transport.TSocket.TSocket(host, port)
import thrift_sasl
_transport = thrift_sasl.TSaslClientTransport(sasl_factory, sasl_auth, socket)
socket.open()
_transport.open()
print "OK"

def sasl_simplified_code(port, sasl_auth):
print "SASL Simplified Code ----------------------------------------------------"
socket = thrift.transport.TSocket.TSocket(host, port)

socket.open()
sasl_x = sasl_factory()
ret, chosen_mech, initial_response = sasl_x.start(sasl_auth)
if not ret:
print "Could not start SASL: %s" % sasl_x.getError()
else:
print "OK"
socket.close()

if __name__ == "__main__":
host = ' NAME.bigdata.XXXXX.br'
port = '2181'
kerberos_service_name = 'hive'
sasl_auth = 'GSSAPI' # KERBEROS
try:
pyhive_simplified(port, sasl_auth)
except Exception as e:
print str(e)
sasl_simplified_code(port, sasl_auth)

--------------------------------------------------------------------

result:

--------------------------------------------------------------------

$ ./t.py
PyHive Simplified code ----------------------------------------------------
Could not start SASL: Error in sasl_client_start (-4) SASL(-4): no mechanism available: No worthy mechs found
SASL Simplified Code ----------------------------------------------------
Could not start SASL: Error in sasl_client_start (-4) SASL(-4): no mechanism available: No worthy mechs found

Thanks in advance and best regards,

Sardano

1 REPLY 1
Highlighted

Re: [help] PyHive don't connect - Kerberized Cluster

New Contributor

Setting up following environment variable worked for me: SASL_PATH=/usr/lib/x86_64-linux-gnu/sasl2 (this on Ubuntu).

Don't have an account?
Coming from Hortonworks? Activate your account here