简体   繁体   English

Hadoop文件系统中目录的路径是什么?

[英]What is the path to directory within Hadoop filesystem?

Recently I start learning Hadoop and Mahout. 最近我开始学习Hadoop和Mahout。 I want to know the path to directory within Hadoop filesystem directory. 我想知道Hadoop文件系统目录中的目录路径。

In hadoop-1.2.1/conf/core-site.xml, I have specified: 在hadoop-1.2.1 / conf / core-site.xml中,我指定了:

<property>
  <name>hadoop.tmp.dir</name>
  <value>/Users/Li/File/Java/hdfstmp</value>
  <description>A base for other temporary directories.</description>
</property>

In Hadoop filesystem, I have the following directories: 在Hadoop文件系统中,我有以下目录:

lis-macbook-pro:Java Li$ hadoop fs -ls
Found 4 items
drwxr-xr-x   - Li supergroup          0 2013-11-06 17:25 /user/Li/output
drwxr-xr-x   - Li supergroup          0 2013-11-06 17:24 /user/Li/temp
drwxr-xr-x   - Li supergroup          0 2013-11-06 14:50 /user/Li/tweets-seq
-rw-r--r--   1 Li supergroup    1979173 2013-11-05 15:50 /user/Li/u.data

Now where is /user/Li/output directory? 现在/ user / Li /输出目录在哪里?

I tried: 我试过了:

lis-macbook-pro:usr Li$ cd /user/Li/output
-bash: cd: /user/Li/output: No such file or directory

So I think /user/Li/output is a relative path not an absolute path. 所以我认为/ user / Li / output是相对路径而不是绝对路径。

Then I search for it in /Users/Li/File/Java/hdfstmp. 然后我在/ Users / Li / File / Java / hdfstmp中搜索它。 There are two folders: 有两个文件夹:

dfs DFS

mapred mapred

But still I cant find /user/Li/output within /Users/Li/File/Java/hdfstmp. 但我仍然无法在/ Users / Li / File / Java / hdfstmp中找到/ user / Li / output。

Your first call to hadoop fs -ls is a relative directory listing, for the current user typically rooted in a directory called /user/${user.name} in HDFS. 您对hadoop fs -ls第一次调用是相对目录列表,对于当前用户通常以HDFS中名为/user/${user.name}的目录为根。 So your hadoop fs -ls command is listing files / directories relative to this location - in your case /user/Li/ 所以你的hadoop fs -ls命令列出了相对于这个位置的文件/目录 - 在你的情况下/user/Li/

You should be able to assert this by running a aboolute listing and confirm the contents / output match: hadoop fs -ls /user/Li/ 您应该能够通过运行aboolute列表并确认内容/输出匹配来断言: hadoop fs -ls /user/Li/

As these files are in HDFS, you will not be able to find them on the local filesystem - they are distributed across your cluster nodes as blocks (for real files), and metadata entries (for files and directories) in the NameNode. 由于这些文件位于HDFS中,因此您无法在本地文件系统中找到它们 - 它们作为块(对于真实文件)分布在群集节点上,并在NameNode中分布在元数据条目(对于文件和目录)中。

All the files are present under hdfs which is Hadoop Distributed File System. 所有文件都存在于hdfs下,即Hadoop分布式文件系统。 so these files are not present in your filesystem or your directory structure 所以这些文件不存在于您的文件系统或目录结构中

inside hdfs these are stored as 在hdfs里面这些存储为

Path("hdfs://host:port/file"));

The setting of the port is present in your xml file under configuration directory of hadoop $HADOOP_HOME/etc/hadoop/core-site.xml 端口的设置存在于hadoop $ HADOOP_HOME / etc / hadoop / core-site.xml配置目录下的xml文件中

<property>
    <name>fs.defaultFS</name>
    <value>hdfs://localhost:9010</value>
</property>

you can view the file present under hdfs with the help of command line 您可以在命令行的帮助下查看hdfs下的文件

hdfs dfs -ls

Basic linux command can be run from the command line 可以从命令行运行基本的linux命令

hdfs dfs -<Command>

with the help of this you can create dir delete file or dir and other things also 借助于此,您还可以创建dir删除文件或目录等

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM