使用 jdbc 从远程 Windows 系统连接到 kerberised hive [英] Connect to kerberised hive using jdbc from remote windows system

查看:30
本文介绍了使用 jdbc 从远程 Windows 系统连接到 kerberised hive的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在 Linux 服务器 (Red Hat) 上设置了启用 Kerberos 安全性的 hive 环境.我需要使用 JDBC 从远程 Windows 机器连接到 hive.

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.

所以,我在 linux 机器上运行了 hiveserver2,并且我已经完成了kinit".

So, I have hiveserver2 running in the linux machine, and I have done "kinit".

现在我尝试使用这样的测试程序从 windows 端的 java 程序连接,

Now I try to connect from a java program on the windows side with a test program like this,

Class.forName("org.apache.hive.jdbc.HiveDriver");
String url = "jdbc:hive2://<host>:10000/default;principal=hive/_HOST@<YOUR-REALM.COM>"
Connection con = DriverManager.getConnection(url);

我收到以下错误,

Exception due to: Could not open client transport with JDBC Uri:
 jdbc:hive2://<host>:10000/;principal=hive/_HOST@YOUR-REALM.COM>: 
GSS initiate failed

我在这里做错了什么?我查了很多论坛,但找不到合适的解决方案.任何答案将不胜感激.

What am I doing here wrong ? I checked many forums, but couldn't get a proper solution. Any answer will be appreciated.

谢谢

推荐答案

如果你在 Linux 中运行你的代码,我会简单地指出 该帖子 -- 即您必须使用系统属性来定义 Kerberos 和 JAAS 配置,来自具有特定格式的 conf 文件.
并且您必须切换调试跟踪标志以了解 subtile 配置问题(即,不同风格/版本的 JVM 可能具有不同的语法要求,这些要求没有记录在案,这是一个反复试验的过程).

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).

但是在 Windows 上还有其他问题:

  1. Apache Hive JDBC 驱动程序对 Hadoop JAR 有一些依赖性,尤其是在涉及 Kerberos 时(请参阅该帖子 详情)
  2. 这些 Hadoop JAR 需要本机库"——即 Hadoop 的 Windows 端口(你必须自己编译!!或者从网络上的不安全来源下载!!)——加上系统属性 hadoop.home.dirjava.library.path 分别指向 Hadoop 主目录及其 bin 子目录
  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

最重要的是,Apache Hive 驱动程序存在兼容性问题——只要有线协议发生变化,新客户端就无法连接到旧服务器.

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.

因此,我强烈建议您为您的 Windows 客户端使用 适用于 Hive 的 Cloudera JDBC 驱动程序.Cloudera 网站只是询问您的电子邮件.
之后,您需要阅读 80 多页的 PDF 手册,要添加到 CLASSPATH 的 JAR,以及要根据手册进行调整的 JDBC URL.
旁注:Cloudera 驱动程序是一个适当的 JDBC-4.x 兼容驱动程序,不需要旧的 Class.forName()...

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()...

这篇关于使用 jdbc 从远程 Windows 系统连接到 kerberised hive的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆