gpt4 book ai didi

hadoop - hadoop书籍示例中的conf文件

转载 作者:可可西里 更新时间:2023-11-01 14:54:52 25 4
gpt4 key购买 nike

我开始使用 hadoop,安装了 1.1.1 版本并运行了“Hadoop 权威指南”中的示例 5-3。
它确实打印出一些配置属性,但我无法在 hadoop 安装或示例代码中找到那些 xml 文件。

以下代码假定添加到配置的 xml 文件存在于某处,但我找不到它们。

编辑:mapred-site.xml 和 hdfs-site.xml 在 hadoop 安装的 conf 文件夹中,但它们是空的。所以我认为它不会使用它们。

构建本书示例后,我转到包含 ch-05.jar 的第 5 章目录并运行以下命令:$asd> hadoop jar ch05-3.0.jar ConfigurationPrinter

public class ConfigurationPrinter extends Configured implements Tool {
static {
Configuration.addDefaultResource("hdfs-default.xml");
Configuration.addDefaultResource("hdfs-site.xml");
Configuration.addDefaultResource("mapred-default.xml");
Configuration.addDefaultResource("mapred-site.xml");
}
@Override
public int run(String[] args) throws Exception {
Configuration conf = getConf();
for (Entry<String, String> entry: conf) {
System.out.printf("%s=%s\n", entry.getKey(), entry.getValue());
}
return 0;
}
}
public static void main(String[] args) throws Exception {
int exitCode = ToolRunner.run(new ConfigurationPrinter(), args);
System.exit(exitCode);
}

最佳答案

您会在 hadoop-core-X.X.jar 中找到 {core|mapred|hdfs}-default 文件。

关于hadoop - hadoop书籍示例中的conf文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14394043/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com