によってプロパティを設定する方法しか見つけられませんhadoop dfsadmin -D xx=yy
。
xx
しかし、コマンドラインで特定のプロパティの値を見つけるにはどうすればよいですか?
によってプロパティを設定する方法しか見つけられませんhadoop dfsadmin -D xx=yy
。
xx
しかし、コマンドラインで特定のプロパティの値を見つけるにはどうすればよいですか?
構成から特定のキーを取得します
hdfs getconf -confKey [key]
hdfs getconf -confKey dfs.replication
https://hadoop.apache.org/docs/r2.7.1/hadoop-project-dist/hadoop-hdfs/HDFSCommands.html#getconf
GenericOptionsParser を使用して、Hadoop の設定を構成型オブジェクトに読み込み、そのプロパティを反復処理できます。これは、ユーティリティ クラス (Configured) によるこのアプローチを示す例です。
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);
}
}