问题
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.
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
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
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