【问题标题】:Connectivity of Hive and Hdinsight with python on AzureHive 和 Hdinsight 与 Azure 上的 python 的连接
【发布时间】:2019-10-31 16:45:51
【问题描述】:

我想使用 python 脚本将 hive 与 hdinsight 集群连接,但由于访问问题无法访问集群仪表板,这将为我提供有助于与 hive 建立连接的 JDBC url 信息。

谁能帮助/推荐我在 python 的帮助下将 hive 与 hdinsight 集群连接的方法。

import jaydebeapi
conn = jaydebeapi.connect("org.apache.hive.jdbc.HiveDriver",
       "jdbc:hive2://16.4.5.492:451/default/;ssl=true;transportMode=http;httpPath=/hive2", 
       ['Username', 'Password'],
       ["/jdbc/hive-jdbc-1.2.1-standalone.jar",
        "/jdbc/httpclient-4.4.jar",
        "/jdbc/httpcore-4.4.4.jar"])

【问题讨论】:

    标签: python azure hadoop hive azure-hdinsight


    【解决方案1】:

    WebHCat 是用于 HCatalog 的 REST API,是 Apache Hadoop 的表和存储管理层。 WebHCat is enabled by default on HDInsight clusters,被各种工具用来在不登录集群的情况下提交作业、获取作业状态等。因此,简而言之,您可以使用 WebHCat 在 Python 中运行 Hive QL。

    补充参考:

    https://cwiki.apache.org/confluence/display/Hive/WebHCat https://social.msdn.microsoft.com/Forums/en-US/b8026143-975f-46c9-b937-99f604e3b757/connect-to-hive-in-hdinsight-using-python-app-on-remote-linuxbased-server?forum=hdinsight

    此外,您可以参考以下文档以使其与 JDBC 驱动程序一起使用:

    https://github.com/uglide/azure-content/blob/master/articles/hdinsight/hdinsight-connect-hive-jdbc-driver.md

    这个我没试过,但是一旦配置完成,你应该可以使用下面的代码进行查询了。

    import jaydebeapi
    conn = jaydebeapi.connect("org.apache.hive.jdbc.HiveDriver",
           "jdbc:hive2://my_ip_or_url:443/;ssl=true;transportMode=http;httpPath=/hive2", 
           [username, password],
           "/jdbc/hive-jdbc-1.2.1.jar")
    

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-06-22
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多