URI to access a file in HDFS

nish1013 picture nish1013 · Dec 21, 2015 · Viewed 13.7k times · Source

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.

Answer

Manjunath Ballur picture Manjunath Ballur · Dec 21, 2015

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.