1
JDBC를 통해 Hive-Server2에 연결하려고합니다. 서버가 kerberos를 사용할 수 있습니다. 나는 다음과 같은 코드를 사용하고Hive JDBC Kerberos 연결 오류
, 나는 키 탭 파일이
내가 무엇을 놓치고 존재하는 에지 노드의 코드를 실행하고?
import org.apache.hadoop.security.UserGroupInformation;
public class HiveJdbcClient {
private static String driverName = "org.apache.hive.jdbc.HiveDriver";
public static void main(String[] args)
throws SQLException, IOException, ClassNotFoundException {
org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration();
conf.set("hadoop.security.authentication", "Kerberos");
UserGroupInformation.setConfiguration(conf);
int ch = 1;
String USER = (ch == 0) ? "hive/[email protected]_DEV9.xyz.COM"
: "[email protected]_DEV9.xyz.COM";
String PASSWORD = (ch == 0) ? "/etc/security/keytabs/hive.service.keytab"
: "/u/users/abcd/.abcd.keytab";
System.out.println("User = " + USER + "Keytab =" + PASSWORD);
File f = new File(PASSWORD);
if (f.exists()) {
System.out.println("File exists");
} else {
System.out.println("File not exists");
}
UserGroupInformation.loginUserFromKeytab(USER, PASSWORD);
String ConnectionURL = "jdbc:hive2://tstr400382.xyz.com:2181,tstr400383.xyz.com:2181,tstr400384.xyz.com:2181,tstr400386.xyz.com:2181,tstr400387.xyz.com:2181/;"
+ "serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2"
+ ";principal=hive/[email protected]_DEV9.xyz.COM;transportMode=http;httpPath=cliservice";
System.out.println("below connection url");
Class.forName(driverName);
Connection con = DriverManager.getConnection(ConnectionURL);
Statement stmt = con.createStatement();
String sql = "show databases;";
System.out.println("Running: " + sql);
ResultSet res = stmt.executeQuery(sql);
if (res.next()) {
System.out.println(res.getString(1));
}
}
}
나는 점점 오전 오류 다음 내가 키 탭에
kinit -kt /u/users/abcd/.abcd.keytab [email protected]_DEV9.xyz.COM
klist를 할 수 있어요
Exception in thread "main" java.io.IOException: Login failure for [email protected]_DEV9.xyz.COM from keytab /u/users/abcd/.abcd.keytab: javax.security.auth.login.LoginException: Unable to obtain password from user
at org.apache.hadoop.security.UserGroupInformation.loginUserFromKeytab(UserGroupInformation.java:1098)
at hadoop.test.HiveJdbcClient.main(HiveJdbcClient.java:42)
Caused by: javax.security.auth.login.LoginException: Unable to obtain password from user
at com.sun.security.auth.module.Krb5LoginModule.promptForPass(Krb5LoginModule.java:897)
at com.sun.security.auth.module.Krb5LoginModule.attemptAuthentication(Krb5LoginModule.java:760)
at com.sun.security.auth.module.Krb5LoginModule.login(Krb5LoginModule.java:617)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at javax.security.auth.login.LoginContext.invoke(LoginContext.java:755)
at javax.security.auth.login.LoginContext.access$000(LoginContext.java:195)
at javax.security.auth.login.LoginContext$4.run(LoginContext.java:682)
at javax.security.auth.login.LoginContext$4.run(LoginContext.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
at javax.security.auth.login.LoginContext.login(LoginContext.java:587)
at org.apache.hadoop.security.UserGroupInformation.loginUserFromKeytab(UserGroupInformation.java:1089)
Keytab name: FILE:.abcd.keytab
KVNO Principal
---- --------------------------------------------------------------------------
1 [email protected]_DEV9.xyz.COM
1 [email protected]_DEV9.xyz.COM
나는 오랫동안에서 붙어 있어요 ,도와주세요.
나는 학습 this을 사용하고 난
사육사 구성 관리 용입니다. 동일한 URL을 사용하여 선을 통해 연결할 수 있습니다. 문제는 UserGroupInformation.loginUserFromKeytab (USER, PASSWORD); –
@ayushnigam 귀하의 답변에 따라 답변을 변경했습니다. – Marco99