Hadoop:hadoop fs、hadoop dfs与hdfs dfs命令的区别

http://blog.csdn.net/pipisorry/article/details/51340838

‘Hadoop DFS‘和‘Hadoop FS‘的区别

While exploring HDFS, I came across these two syntaxes for querying HDFS:

> hadoop dfs

> hadoop fs

why we have two different syntaxes for a common purpose

为什么会对同一个功能提供两种命令标记?

命令的定义

it seems like there‘s no difference between the two syntaxes. If we look at the definitions of the two commands (hadoop fs and hadoop dfs) in $HADOOP_HOME/bin/hadoop

从两个命令的定义中(在$HADOOP_HOME/bin/hadoop)可以看到这两者之间似乎没有什么区别。

...

elif [ "$COMMAND" = "datanode" ] ; then

CLASS=‘org.apache.hadoop.hdfs.server.datanode.DataNode‘

HADOOP_OPTS="$HADOOP_OPTS $HADOOP_DATANODE_OPTS"

elif [ "$COMMAND" = "fs" ] ; then

CLASS=org.apache.hadoop.fs.FsShell

HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"

elif [ "$COMMAND" = "dfs" ] ; then

CLASS=org.apache.hadoop.fs.FsShell

HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"

elif [ "$COMMAND" = "dfsadmin" ] ; then

CLASS=org.apache.hadoop.hdfs.tools.DFSAdmin

HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"

...

貌似更有道理的解释

Unconvinced, and these excerpts made more sense to me:

FS relates to a generic file system which can point to any file systems like local, HDFS etc. But dfs is very specific to HDFS. So when we use FS it?can perform operation with from/to local or
hadoop distributed file system to destination. But specifying DFS operation relates to?HDFS.

这个理由并不完全信服,下面这个解释貌似更有道理:

FS涉及到一个通用的文件系统,可以指向任何的文件系统如local,HDFS等。

但是DFS仅是针对HDFS的。

那么什么时候用FS呢?可以在本地与hadoop分布式文件系统的交互操作中使用。特定的DFS指令与HDFS有关。

Hadoop文档对这两个不同的shell的描述

Below are two excerpts from the Hadoop documentation that describe these two as different shells.

下面是两个摘录Hadoop文档,描述这两个不同的shell。

  1. FS Shell
  2. The FileSystem (FS) shell is invoked by bin/hadoop fs. All the FS shell commands take path URIs as arguments. The URI format is scheme://autority/path. For HDFS the scheme is hdfs, and for the local filesystem the scheme is file. The scheme and authority are optional. If not specified, the default scheme specified in the configuration is used. An HDFS file or directory such as /parent/child can be specified as hdfs://namenodehost/parent/child or simply as /parent/child (given that your configuration is set to point to hdfs://namenodehost). Most of the commands in FS shell behave like corresponding Unix commands.?
  1. DFShell
  2. The HDFS shell is invoked by bin/hadoop dfs. All the HDFS shell commands take path URIs as arguments. The URI format is scheme://autority/path. For HDFS the scheme is hdfs, and for the local filesystem the scheme is file. The scheme and authority are optional. If not specified, the default scheme specified in the configuration is used. An HDFS file or directory such as /parent/child can be specified as hdfs://namenode:namenodeport/parent/child or simply as /parent/child (given that your configuration is set to point to namenode:namenodeport). Most of the commands in HDFS shell behave like corresponding Unix commands.?

So, based on the above, we can conclude that it all depends on the scheme configuration. When using these two commands with absolute URI (i.e. scheme://a/b) the?behavior?shall be identical. Only it‘s the default configured scheme value for file and hdfs
for fs and dfs respectively, which is the cause for difference in?behavior.

由上述内容可以看出来,这两个命令依赖于模式的配置。当使用绝对URI(如scheme://a/b)这两个命令式相同的。只有默认的模式配置参数对dfs和fs起作用。

[http://java.dzone.com/articles/difference-between-hadoop-dfs]

皮皮blog

stackoverflow的解释

Hadoop fs:使用面最广,可以操作任何文件系统。

hadoop dfs与hdfs dfs:只能操作HDFS文件系统相关(包括与Local FS间的操作),前者已经Deprecated,一般使用后者。

Following are the three commands which appears same but have minute differences

  1. hadoop fs {args}
  2. hadoop dfs {args}
  3. hdfs dfs {args}
    hadoop fs <args>
    

FS relates to a generic file system which can point to any file systems like local, HDFS etc. So this can be used when you are dealing with different file systems such as Local FS, HFTP FS, S3 FS, and others

  hadoop dfs <args>

dfs is very specific to HDFS. would work for operation relates to HDFS. This has been deprecated and we should use hdfs dfs instead.

  hdfs   dfs <args>

same as 2nd i.e would work for all the operations related to HDFS and is the recommended command instead of hadoop dfs

below is the list categorized as HDFS commands.

  **#hdfs commands**
  namenode|secondarynamenode|datanode|dfs|dfsadmin|fsck|balancer|fetchdt|oiv|dfsgroups

So even if you use Hadoop dfs , it will look locate hdfs and delegate that command to hdfs dfs

[何时使用hadoop fs、hadoop dfs与hdfs dfs命令]

from: http://blog.csdn.net/pipisorry/article/details/51340838

ref:

时间: 2024-07-30 22:01:34

Hadoop:hadoop fs、hadoop dfs与hdfs dfs命令的区别的相关文章

何时使用hadoop fs、hadoop dfs与hdfs dfs命令

hadoop fs:使用面最广,可以操作任何文件系统. hadoop dfs与hdfs dfs:只能操作HDFS文件系统相关(包括与Local FS间的操作),前者已经Deprecated,一般使用后者. 以下内容参考自stackoverflow Following are the three commands which appears same but have minute differences hadoop fs {args} hadoop dfs {args} hdfs dfs {a

Hadoop 配置(3)---使用 HDFS

伪分布式读取的则是 HDFS 上的数据.要使用 HDFS,首先需要在 HDFS 中创建用户目录: ./bin/hdfs dfs -mkdir -p /user/hadoop 接着将 ./etc/hadoop 中的 xml 文件作为输入文件复制到分布式文件系统中,即将 /usr/local/hadoop/etc/hadoop 复制到分布式文件系统中的 /user/hadoop/input 中. ./bin/hdfs dfs -mkdir input ./bin/hdfs dfs -put ./et

HDFS常用命令总结

hdfs文件的相关操作主要使用hadoop fs.hadoop dfs.hdfs dfs 命令,以下对最常用的相关命令进行简要说明.hadoop fs -ls  显示当前目录结构,-ls -R 递归显示目录结构hadoop fs -mkdir  创建目录hadoop fs -rm   删除文件,-rm -R 递归删除目录和文件hadoop fs -put  [localsrc] [dst]  从本地加载文件到HDFShadoop fs -get  [dst] [localsrc]  从HDFS导

Hadoop学习笔记_7_分布式文件系统HDFS --DataNode体系结构

分布式文件系统HDFS --DataNode体系结构 1.概述 DataNode作用:提供真实文件数据的存储服务. 文件块(block):最基本的存储单位[沿用的Linux操作系统地概念].对于文件内容而言,一个文件的长度大小是size,那么从文件的0偏移开始,按照固定的大小,顺序对文件进行划分并编号,划分好的每一个块称一个Block. 与Linux操作系统不同的是,一旦上传了一个小于Block大小的文件,则该文件会占用实际文件大小的空间. 2.进入hdfs-default.xml <prope

[hadoop读书笔记] 第三章 HDFS

P49 当数据集的大小超过一台计算机存储能力时,就有必要对数据集分区(partition)并将分区存储到若干台独立的计算机上. 管理网络中跨多台计算机存储的系统就叫分布式文件系统  Distributed FileSystem 而基于Hadoop构建的DFS就称之为HDFS. P49-50 HDFS的设计思路:以流数据访问模式来存储超大文件,运行在商用硬件集群上. P51 HDFS 数据块:默认为64MB,是HDFS进行数据读写的最小单位,作为独立的存储单元存在. 一个打文件可以切分为多个块存储

hadoop配置及无法移动文件到hdfs故障解析

首先博主用的64位ubuntu,hadoop官方只提供32位版本,这样的话启动本地库无法兼容,需要自己编译为64位版本,或下载别人编译好的64位版本. 下载好需要在etc/hadoop目录下改动以下几个配置 其中hadoop-env.sh中需要指定JAVA_HOME export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_75 core-site.xml配置 <configuration> <property> <name>fs.default.n

【甘道夫】Apache Hadoop 2.5.0-cdh5.2.0 HDFS Quotas 配额控制

前言 HDFS为管理员提供了针对文件夹的配额控制特性,能够控制名称配额(指定文件夹下的文件&文件夹总数),或者空间配额(占用磁盘空间的上限). 本文探究了HDFS的配额控制特性,记录了各类配额控制场景的实验具体过程. 实验环境基于Apache Hadoop 2.5.0-cdh5.2.0. 欢迎转载,请注明出处:http://blog.csdn.net/u010967382/article/details/44452485 名称配额功能试用 设置名称配额,即当前文件夹下文件和文件夹的最大数量: [

介绍hadoop中的hadoop和hdfs命令

有些hive安装文档提到了hdfs dfs -mkdir ,也就是说hdfs也是可以用的,但在2.8.0中已经不那么处理了,之所以还可以使用,是为了向下兼容. 本文简要介绍一下有关的命令,以便对hadoop的命令有一个大概的影响,并在想使用的时候能够知道从哪里可以获得帮助. 概述 在$HADOOP_HOME/bin下可以看到hadoop和hdfs的脚本. hdfs的相当一部分的功能可以使用hdoop来替代(目前),但hdfs有自己的一些独有的功能.hadoop主要面向更广泛复杂的功能. 本文介绍

Apache hadoop namenode ha和yarn ha ---HDFS高可用性

HDFS高可用性Hadoop HDFS 的两大问题:NameNode单点:虽然有StandbyNameNode,但是冷备方案,达不到高可用--阶段性的合并edits和fsimage,以缩短集群启动的时间--当NameNode失效的时候,Secondary NN并无法立刻提供服务,Secondary NN甚至无法保证数据完整性--如果NN数据丢失的话,在上一次合并后的文件系统的改动会丢失NameNode扩展性问题:单NameNode元数据不可扩展,是整个HDFS集群的瓶颈 Hadoop HDFS高