【发布时间】:2018-04-26 13:21:27
【问题描述】:
我正在尝试使用以下方法在 HDFS 中创建文件:
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
为此,我添加如下配置:
Configuration configuration = new Configuration();
configuration.set("fs.hdfs.impl",
org.apache.hadoop.hdfs.DistributedFileSystem.class.getName()
);
configuration.set("fs.file.impl",
org.apache.hadoop.fs.LocalFileSystem.class.getName()
);
OutputStream fileout1 = new FileOutputStream("CONF_before.XML");
configuration.writeXml(fileout1);
configuration.addResource(new Path("/etc/hive/conf.cloudera.hive/hdfs-site.xml"));
configuration.addResource(new Path("/etc/hive/conf.cloudera.hive/core-site.xml"));
OutputStream fileout = new FileOutputStream("CONF_after.XML");
configuration.writeXml(fileout);
FileSystem hdfs = FileSystem.get(configuration);
Path out_path = new Path(hdfs.getWorkingDirectory() + "/OD.xml");
OutputStream os = hdfs.create(out_path);
运行此代码时,OutputStream os = hdfs.create(out_path) 出现错误:
Caused by: org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.security.AccessControlException): SIMPLE authentication is not enabled. Available:[TOKEN,KERBEROS]
但如果我将core-site.xml 添加到项目工件并在服务器上运行它,则不会出现错误。
两种情况下的输出配置相同。 core-site.xml 的相关部分是:
<property>
<name>hadoop.security.authentication</name>
<value>kerberos</value>
</property>
<property>
<name>hadoop.security.authorization</name>
<value>false</value>
</property>
<property>
<name>hadoop.rpc.protection</name>
<value>authentication</value>
</property>
任何想法为什么会发生? 谢谢!
【问题讨论】: