[英]HDFS access from remote host through Java API, user authentication
[英]How to access configuration xml files of remote HDFS cluster using Java API?
我有一個namenode地址(ip地址和端口),但是我不知道本地文件系統上配置文件(即core-site.xml,hdfs-site.xml等)的位置。 我想訪問配置詳細信息。
我知道通過執行以下操作可以獲得詳細信息,
Configuration conf = new Configuration();
conf.addResource(file path of core-site.xml);
conf.addResource(file path of hdfs-site.xml);
它在我知道文件路徑的本地計算機上工作。 但是我不知道遠程計算機上文件的位置。
有什么方法可以訪問配置?
如果真正的問題是如何在一個群集中運行代碼並在另一個群集上訪問HDFS,則無需像大多數教程所示的那樣添加Resource core-site.xml和hdfs-site.xml。
Configuration conf = new Configuration();
//conf.addResource(new Path("/etc/hadoop/conf/core-site.xml"));
//conf.addResource(new Path("/etc/hadoop/conf/hdfs-site.xml"));
//FileSystem fs = FileSystem.get(conf);
String fromFileName = "hdfs://my.source.cluster/a/b/c";
String toFileName = "hdfs://my.dest.cluster/d/e/f";
FileSystem fromFs = FileSystem.get(new URI(fromFileName),conf);
FileSystem toFs = FileSystem.get(new URI(toFileName),conf);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.