使用python将配置单元与keytab连接

2024-03-29 05:52:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在寻找一个使用python将配置单元与keytab连接起来的选项。尝试使用Jaydebeapi选项建立连接,但尚未成功

import jaydebeapi

DIR = root_path
jarFile = [ DIR + 'hive-jdbc-2.3.7.jar',
        DIR + 'commons-logging-1.2.jar',
        DIR + 'hive-service-3.1.1.jar',
        DIR + 'hive-service-rpc-3.1.1.jar',
        DIR + 'libthrift-0.12.0.jar',
        DIR + 'httpclient-4.5.9.jar',
        DIR + 'httpcore-4.4.11.jar',
        DIR + 'slf4j-api-1.7.26.jar',
        DIR + 'curator-framework-4.2.0.jar',
        DIR + 'curator-recipes-4.2.0.jar',
        DIR + 'curator-client-4.2.0.jar',
        DIR + 'commons-lang-2.6.jar',
        DIR + 'hadoop-common-3.2.0.jar',
        DIR + 'httpcore-4.4.11.jar',
        DIR + 'hive-common-3.1.1.jar',
        DIR + 'hive-serde-3.1.1.jar',
        DIR + 'guava-28.0-jre.jar',
        DIR + 'zookeeper-3.4.6.jar',
        DIR + 'hive-shims-common-2.1.0.jar']

   dirver = 'org.apache.hive.jdbc.HiveDriver' 

  # JDBC connection string
  url=["jdbc:hive2://' +server_with_port 
  +'/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2;principal=hive/_HOST@_REALM;"]

 #Connect to HiveServer2
 conn=jaydebeapi.connect(dirver, url, jars=jarFile)

当我运行这段代码时,我得到如下错误 return jpype.java.sql.DriverManager.getConnection(url, *dargs) RuntimeError: No matching overloads found for getConnection in find. at native\common\jp_method.cpp:127

尝试了pyHive选项,但sasl安装在windows中失败,无法继续。此外,我不确定是否有可能在pyHive中使用keytab文件

如果您有更好的解决方案,请提出建议

提前谢谢


Tags: url选项dirservicecommonjarhivecommons