Connect to kerberised hive using jdbc from remote windows system

前端 未结 3 1036
时光取名叫无心
时光取名叫无心 2020-12-21 13:39

I have setup a hive environment with Kerberos security enabled on a Linux server (Red Hat). And I need to connect from a remote windows machine to hive using JDBC.

S

相关标签:
3条回答
  • 2020-12-21 13:59

    The key for us when we ran into the problem, was as follows:

    On your server there are certain kerberos principals listed that are allowed to operate on the data.

    When we tried to run a query via JDBC, we didn't do the proper kinit on the client side.

    In this case the solution is obvious:

    On the windows client: do a kinit with the proper account before connecting

    0 讨论(0)
  • 2020-12-21 14:01
    String url = "jdbc:hive2://<host>:10000/default;principal=hive/_HOST@<YOUR-REALM.COM>"
    

    You should replace <YOUR-REALM.COM> with your real REALM.

    0 讨论(0)
  • 2020-12-21 14:12

    If you were running your code in Linux, I would simply point to that post -- i.e. you must use System properties to define Kerberos and JAAS configuration, from conf files with specific formats.
    And you have to switch the debug trace flags to understand subtile configuration issue (i.e. different flavors/versions of JVMs may have different syntax requirements, which are not documented, it's a trial-and-error process).

    But on Windows there are additional problems:

    1. the Apache Hive JDBC driver has some dependencies on Hadoop JARs, especially when Kerberos is involved (see that post for details)
    2. these Hadoop JARs require "native libraries" -- i.e. a Windows port of Hadoop (which you have to compile yourself!! or download from an insecure source on the web!!) -- plus System properties hadoop.home.dir and java.library.path pointing to the Hadoop home dir and its bin sub-dir respectively

    On the top of that, the Apache Hive driver has compatibility issues -- whenever there are changes in the wire protocol, newer clients cannot connect to older servers.

    So I strongly advise you to use the Cloudera JDBC driver for Hive for your Windows clients. The Cloudera site just asks your e-mail.
    After that you have a 80+ pages PDF manual to read, the JARs to add to your CLASSPATH, and your JDBC URL to adapt according to the manual.
    Side note: the Cloudera driver is a proper JDBC-4.x compliant driver, no need for that legacy Class.forName()...

    0 讨论(0)
提交回复
热议问题