在浏览器中打开hdfs文件

mrfwxfqh  于 2021-06-04  发布在  Hadoop
关注(0)|答案(1)|浏览(742)

我正在尝试使用以下url在浏览器中打开一个文件(位于hdfs位置:/user/input/summary.txt中):hdfs://localhost:8020/user/input/summary.txt但我的firefox浏览器中出现错误: Firefox doesn't know how to open this address, because the protocol (hdfs) isn't associated with any program. 如果我把协议从 hdfshttp (这在理想情况下是行不通的)那么我得到的信息是: It looks like you are making an HTTP request to a Hadoop IPC port. This is not the correct port for the web interface on this daemon. 这在 core-site.xml 文件:

<property>
    <name>fs.default.name</name>
    <value>hdfs://localhost:8020</value>
  </property>

请让我知道如何使这项工作。我不确定问题是否与firefox浏览器有关,或者我缺少一些配置设置,或者我使用了不正确的url。
编辑:
当我尝试从java代码访问它时,我得到一个异常: unknown protocol: hdfs .

static{
    URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory());
}

public static void main(String[] args) throws MalformedURLException, IOException {
    final String url = "hdfs://localhost:8020/user/input/Summary.txt";

    InputStream is = new URL(url).openStream();

}

请建议如何访问 hdfs protocol 来自java代码。

xxls0lw8

xxls0lw81#

在hdfs8020是ipc端口,您需要打开hdfs浏览器的hdfs web ui,它的默认端口是50070,从您的web浏览器打开以下url http://localhost:50070/ ,然后转到 Live nodes 选项->从那里选择一个datanode->单击browse filesystem

相关问题