代码展示
public class HDFSUtil {
private FileSystem hdfs;
public HDFSUtil(String host, String port) {
this.hdfs = getFileSystem(host, port);
}
private static void kerberosConfig1(Configuration config) {
String krb5File = "D:\\data1\\krb5.conf";
String kerUser = "hdfs-geotmt@GAI.COM";
String keyPath = "D:\\data1\\hdfs.headless.keytab";
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();
}
}
private static void kerberosConfig2(Configuration config) {
String krb5File = "D:\\data1\\krb5.conf";
String kerUser = "hdfs-geotmt@GAI.COM";
String keyPath = "D:\\data1\\hdfs.headless.keytab";
System.setProperty("java.security.krb5.conf", krb5File);
String coreSite = "D:\\data1\\core-site.xml";
String hdfsSite = "D:\\data1\\hdfs-site.xml";
System.setProperty(