org.apache.hadoop
hadoop-hdfs
3.1.1
org.apache.hadoop
hadoop-common
3.1.1
org.apache.hadoop
hadoop-client
3.1.1
认证方法
Configuration config new Configuration();
config.set("fs.hdfs.impl", "org.apache.hadoop.hdfs.DistributedFileSystem");
config.set("dfs.client.block.write.replace-datanode-on-failure.policy", "NEVER");
//开始Kerberos认证
String krb5File "/etc/krb5.conf";
System.setProperty("java.security.krb5.conf", krb5File);
config.set("hadoop.security.authentication", "kerberos");
UserGroupInformation.setConfiguration(config);
try {
UserGroupInformation.loginUserFromKeytab(kerUser, keyPath);
} catch (IOException e) {
e.printStackTrace();
}
//结束Kerberos认证
URI uri new URI("hdfs://" host ":" port);
FileSystem.get(uri, config);
参考博客https://blog.csdn.net/weixin_43989001/article/details/86309512