Java Hadoop 文件系统中的目录路径是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19938606/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the path to directory within Hadoop filesystem?
提问by Li'
Recently I start learning Hadoop and Mahout. I want to know the path to directory within Hadoop filesystem directory.
最近开始学习Hadoop和Mahout。我想知道 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/output 目录在哪里?
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. There are two folders:
然后我在 /Users/Li/File/Java/hdfstmp 中搜索它。有两个文件夹:
dfs
文件系统
mapred
映射
But still I cant find /user/Li/output within /Users/Li/File/Java/hdfstmp.
但我仍然无法在 /Users/Li/File/Java/hdfstmp 中找到 /user/Li/output。
回答by Chris White
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. So your hadoop fs -ls
command is listing files / directories relative to this location - in your case /user/Li/
您的第一个调用hadoop fs -ls
是相对目录列表,当前用户通常根植/user/${user.name}
于 HDFS 中调用的目录。所以你的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/
您应该能够通过运行绝对列表并确认内容/输出匹配来断言这一点: 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 中。
回答by UserszrKs
All the files are present under hdfs which is Hadoop Distributed File System. so these files are not present in your filesystem or your directory structure
所有文件都存在于 hdfs 下,即 Hadoop 分布式文件系统。所以这些文件不存在于您的文件系统或目录结构中
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
端口的设置存在于你的 xml 文件中,位于 hadoop $HADOOP_HOME/etc/hadoop/core-site.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 删除文件或 dir 以及其他内容