我有带 SSL(仅启用最低 TLS1.2)和 LDAP 的 HiveServer2,没有启用 kerberos。hive.server2.transport.mode = 二进制。直线连接可以正常工作,例如:
beeline -u jdbc:hive2://domain:10000/default\;ssl=true\;sslTrustStore=/home/user/query.jks\;trustStorePassword=blah -n user -p pass -e "SELECT * FROM table LIMIT 3"
正如预期的那样,通过直线未传递正确的信任库详细信息或错误的 ldap 凭据意味着连接不起作用。
我想使用 python 库连接到 HiveServer2(特别是这个带有 TLS1.2 的 Hive 设置)。
我查看了几个库,如 impyla、pyhive、pyhs2、sqlalchemy,但没有一个对我有用。我看到其他人提出的几个问题:
- https://community.cloudera.com/t5/Batch-SQL-Apache-Hive/Impyla-TLS-SSL-issues-with-newer-versions-of-SSL/td-p/65136
- https://github.com/cloudera/impyla/issues/293
- https://github.com/dropbox/PyHive/issues/203
- https://github.com/cloudera/impyla/issues/240
- https://github.com/dropbox/PyHive/issues/143
网上有很多没有 TLS1.2 保护的 HiveServer2 实例的连接示例。
`>>> 从 impala.dbapi 导入连接
conn = connect(host='domain', port=10000, use_ssl=True, auth_mechanism='LDAP', user='user', password='pass', ca_cert='/home/user/query.pem') Traceback (最近一次调用最后):文件“”,第 1 行,在文件“/usr/local/lib/python2.7/site-packages/impala/dbapi.py”中,第 147 行,在连接 auth_mechanism=auth_mechanism)文件中“ /usr/local/lib/python2.7/site-packages/impala/hiveserver2.py”,第 658 行,在连接 transport.open() 文件“/usr/local/lib/python2.7/site-packages/thrift_sasl /初始化.py”,第 68 行,打开 self._trans.open() 文件“/usr/local/lib64/python2.7/site-packages/thrift/transport/TSSLSocket.py”,第 118 行,打开 message=message )thrift.transport.TTransport.TTransportException:无法连接到域:10000:[SSL:WRONG_VERSION_NUMBER]版本号错误(_ssl.c:726)`