我有一些使用 HDFS 和 Kerberos 身份验证的集成测试。当我运行它们时,我得到这个异常:
java.io.IOException: Failed on local exception: java.io.IOException: java.lang.IllegalArgumentException: Failed to specify server's Kerberos principal name; Host Details : local host is: "Serbans-MacBook-Pro.local/1.2.3.4"; destination host is: "10.0.3.33":8020;
at org.apache.hadoop.net.NetUtils.wrapException(NetUtils.java:772)
at org.apache.hadoop.ipc.Client.call(Client.java:1472)
at org.apache.hadoop.ipc.Client.call(Client.java:1399)
at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:232)
at com.sun.proxy.$Proxy12.getFileInfo(Unknown Source)
我相信一切都配置正确:
System.setProperty("java.security.krb5.realm", "...");
System.setProperty("java.security.krb5.kdc", "...");
Configuration conf = new Configuration();
conf.set("fs.defaultFS", "hdfs://10.0.3.33:8020");
conf.set("fs.hdfs.impl", "org.apache.hadoop.hdfs.DistributedFileSystem");
conf.set("hadoop.security.authentication", "Kerberos");
UserGroupInformation.setConfiguration(conf);
UserGroupInformation.loginUserFromKeytab("user@...", "/Users/user/user.keytab");
您认为问题出在哪里?在我的主机 (10.0.3.33) 上,我正确配置了 core-site.xml 和 hdfs-site.xml。但正如异常所示,我并没有从该主机运行。
为了能够从任何主机运行测试,有什么想法吗?
谢谢, 塞尔维亚语
最佳答案
如果您使用的是低于 2.6.2 的 Hadoop 旧版本,默认模式属性在 hdfs-site.xml 文件中不可用,那么您需要手动指定模式属性。
config.set("dfs.namenode.kerberos.principal.pattern", "hdfs/*@BDBIZVIZ.COM");
关于hadoop - Java - 无法指定服务器的 Kerberos 主体名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37050626/