Sparkcode 将 Hive 与 kerberos keytab 连接

发布于 2025-01-13 15:20:48 字数 830 浏览 1 评论 0原文

我正在尝试使用 Spark 2.4.5 使用 kerberos keytab 身份验证连接到 Hive 到目前为止,我已经开发了以下代码,我想将其转换为数据帧。 我该如何做到这一点,除此之外还有其他方法可以使用 kerberos keytab 连接到 Hive 吗?

  val conf: org.apache.hadoop.conf.Configuration = new org.apache.hadoop.conf.Configuration()
  System.setProperty("java.security.krb5.conf", krbloc)
  conf.set("hadoop.security.authentication", "kerberos")
  conf.set("hadoop.security.authorization", "true")
  UserGroupInformation.setConfiguration(conf)
  UserGroupInformation.loginUserFromKeytab("[email protected]",
    keytab_path)
  Class.forName("org.apache.hive.jdbc.HiveDriver")

  val con = DriverManager.getConnection(url3)
  con.prepareStatement("select * from table").executeQuery

I am trying to connect to Hive using kerberos keytab authentication using spark 2.4.5
Till now i have developed the below code and i want to convert the same to a dataframe.
How can i do that and is there any other approach to connect to Hive with kerberos keytab apart from this?

  val conf: org.apache.hadoop.conf.Configuration = new org.apache.hadoop.conf.Configuration()
  System.setProperty("java.security.krb5.conf", krbloc)
  conf.set("hadoop.security.authentication", "kerberos")
  conf.set("hadoop.security.authorization", "true")
  UserGroupInformation.setConfiguration(conf)
  UserGroupInformation.loginUserFromKeytab("[email protected]",
    keytab_path)
  Class.forName("org.apache.hive.jdbc.HiveDriver")

  val con = DriverManager.getConnection(url3)
  con.prepareStatement("select * from table").executeQuery

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文