Pau*_*lgo 46
您可以通过运行来转储Hadoop配置:
$ hadoop org.apache.hadoop.conf.Configuration
Run Code Online (Sandbox Code Playgroud)
您可以使用GenericOptionsParser将Hadoop的设置加载到Configuration-typed对象并迭代其属性.以下示例通过实用程序类(已配置)演示此方法.
public class ConfigPrinter extends Configured implements Tool {
static {
// by default core-site.xml is already added
// loading "hdfs-site.xml" from classpath
Configuration.addDefaultResource("hdfs-site.xml");
Configuration.addDefaultResource("mapred-site.xml");
}
@Override
public int run(String[] strings) throws Exception {
Configuration config = this.getConf();
for (Map.Entry<String, String> entry : config) {
System.out.println(entry.getKey() + " = " + entry.getValue());
}
return 0;
}
public static void main(String[] args) throws Exception {
ToolRunner.run(new ConfigPrinter(), args);
}
}
Run Code Online (Sandbox Code Playgroud)
从配置中获取特定键
hdfs getconf -confKey [key]
hdfs getconf -confKey dfs.replication
Run Code Online (Sandbox Code Playgroud)
https://hadoop.apache.org/docs/r2.7.1/hadoop-project-dist/hadoop-hdfs/HDFSCommands.html#getconf
| 归档时间: |
|
| 查看次数: |
13304 次 |
| 最近记录: |