URI to access a file in HDFS

佐手、 提交于 2020-01-23 08:24:45

问题


I have setup a cluster using Ambari that includes 3 nodes .

Now I want to access a file in a HDFS using my client application.

I can find all node URIs under Data Nodes in Amabari.

What is the URI + Port I need to use to access a file ? I have used the default installation process.


回答1:


Default port is "8020".

You can access the "hdfs" paths in 3 different ways.

  1. Simply use "/" as the root path

    For e.g.

    E:\HadoopTests\target>hadoop fs -ls /
    Found 6 items
    drwxrwxrwt   - hadoop  hdfs          0 2015-08-17 18:43 /app-logs
    drwxr-xr-x   - mballur hdfs          0 2015-11-24 15:36 /tmp
    drwxrwxr-x   - mballur hdfs          0 2015-10-20 15:27 /user
    
  2. Use "hdfs:///"

    For e.g.

    E:\HadoopTests\target>hadoop fs -ls hdfs:///
    Found 6 items
    drwxrwxrwt   - hadoop  hdfs          0 2015-08-17 18:43 hdfs:///app-logs
    drwxr-xr-x   - mballur hdfs          0 2015-11-24 15:36 hdfs:///tmp
    drwxrwxr-x   - mballur hdfs          0 2015-10-20 15:27 hdfs:///user
    
  3. Use "hdfs://{NameNodeHost}:8020/"

    For e.g.

    E:\HadoopTests\target>hadoop fs -ls hdfs://MBALLUR:8020/
    Found 6 items
    drwxrwxrwt   - hadoop  hdfs          0 2015-08-17 18:43 hdfs://MBALLUR:8020/app-logs
    drwxr-xr-x   - mballur hdfs          0 2015-11-24 15:36 hdfs://MBALLUR:8020/tmp
    drwxrwxr-x   - mballur hdfs          0 2015-10-20 15:27 hdfs://MBALLUR:8020/user
    

    In this case, "MBALLUR" is the name of my Name Node host.



来源:https://stackoverflow.com/questions/34393139/uri-to-access-a-file-in-hdfs

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