Opening a HDFS file in browser

﹥>﹥吖頭↗ 提交于 2019-12-10 09:43:08

问题


I am trying to open a file (present in the HDFS location: /user/input/Summary.txt) in my browser using the URL: hdfs://localhost:8020/user/input/Summary.txt but I am getting an error in my firefox browser:

Firefox doesn't know how to open this address, because the protocol (hdfs) isn't associated with any program.

If I change the protocol from hdfs to http (which ideally should not work) then I am getting the message: 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.

This is present in the core-site.xml file:

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

Please let me know how to make this work. I am not sure whether the problem is related to firefox browser OR I am missing some configuration settings OR i am using the incorrect url.

EDIT:

When I try to access it from a java code, i get an exception: 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();

}

Please suggest how to access the hdfs protocol from java code.


回答1:


In HDFS 8020 is IPC port, you need to open HDFS Web UI for HDFS browser, It's default port is 50070, Open following URL from your Web Browser

http://localhost:50070/ , then Go to Live nodes option -> Select one of your datanodes from there -> Click on Browse filesystem



来源:https://stackoverflow.com/questions/27996034/opening-a-hdfs-file-in-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!