24

によってプロパティを設定する方法しか見つけられませんhadoop dfsadmin -D xx=yy

xxしかし、コマンドラインで特定のプロパティの値を見つけるにはどうすればよいですか?

4

4 に答える 4

7

構成から特定のキーを取得します

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

于 2019-11-19T12:57:04.843 に答える
6

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);
    }
}
于 2012-10-08T09:59:25.960 に答える