簡體   English   中英

使用jerc和kerberos keytab訪問hive Metastore

[英]Accessing hive metastore using jdbc with kerberos keytab

我正在嘗試連接到已配置為使用Kerberos進行身份驗證的配置單元播放器。 當我不想使用keytab文件時,即當程序在身份驗證過程中提示我輸入密碼時,這對我有用。 當我更改配置以使用keytab時,我得到一個包含此語句的長堆棧跟蹤:

Additional pre-authentication required (25) - Need to use PA-ENC-TIMESTAMP/PA-PK-AS-REQ

誰能就我做錯了什么提出任何建議?

我的問題的上下文,如果相關,是我想從mapreduce作業訪問hive Metastore,當然,mapreduce作業無法回答提示。

我的程序看起來像這樣:

package com.test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class HiveJDBC {

   public static void main(String[] args) throws Exception {

      Class.forName("org.apache.hive.jdbc.HiveDriver");
      System.setProperty("java.security.auth.login.config","gss-jaas.conf");
      System.setProperty("sun.security.jgss.debug","true");
      System.setProperty("javax.security.auth.useSubjectCredsOnly","false");
      System.setProperty("java.security.krb5.conf","krb5.conf");

      Connection con = DriverManager.getConnection("jdbc:hive2://some.machine:10000/default;principal=hive/some.machine@MY_REALM");

      // Do stuff with the connection
   }
}

我的gss-jaas.conf文件如下所示:

com.sun.security.jgss.initiate {
   com.sun.security.auth.module.Krb5LoginModule required
   useKeyTab=true
   useTicketCache=false
   principal="my-account@MY_REALM"
   doNotPrompt=true
   keyTab="path-to-my-keytab-file"
   debug=true;
};

我的krb5.conf文件看起來像這樣

[libdefaults]
default_realm = MY_REALM
dns_lookup_realm = false
dns_lookup_kdc = false
ticket_lifetime = 24h
renew_lifetime = 7d

[realms]     
 MY_REALM = {
  kdc = some.host:88
  admin_server = another.host
 }

我使用以下命令使用ktutil程序生成的keytab文件

ktutil: addent -password -p username@MY_REALM -k 1 -e aes256-cts

顯然,這個錯誤是由於在發出ktutil命令時使用了錯誤的加密類型引起的。 切換到正確的加密(我不會提到我們使用的)解決了這個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM