使用jdbc和kerberos密钥表访问配置单元元存储
我正在尝试连接到配置单元元存储,该元存储已配置为使用Kerberos进行身份验证。当我不尝试使用keytab文件时,即当程序在身份验证过程中提示我输入密码时,这对我有效。当我更改配置以使用keytab时,我会得到一个长stacktrace,其中包含以下语句:使用jdbc和kerberos密钥表访问配置单元元存储,jdbc,hadoop,hive,kerberos,Jdbc,Hadoop,Hive,Kerberos,我正在尝试连接到配置单元元存储,该元存储已配置为使用Kerberos进行身份验证。当我不尝试使用keytab文件时,即当程序在身份验证过程中提示我输入密码时,这对我有效。当我更改配置以使用keytab时,我会得到一个长stacktrace,其中包含以下语句: Additional pre-authentication required (25) - Need to use PA-ENC-TIMESTAMP/PA-PK-AS-REQ 有人能就我做错了什么给出建议吗 如果相关的话,问题的背景是我想
Additional pre-authentication required (25) - Need to use PA-ENC-TIMESTAMP/PA-PK-AS-REQ
有人能就我做错了什么给出建议吗
如果相关的话,问题的背景是我想从mapreduce作业访问配置单元元存储,当然,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
}
}
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;
};
我的gss-jaas.conf文件如下所示:
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
}
}
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命令时使用了错误的加密类型造成的。切换到正确的加密(我不会提及我们使用的加密)解决了这个问题。实际上,这篇文章是我开始使用Hive和Kerberos时所能找到的最好的“快速入门”指南之一。感谢分享示例配置。。。