HADOOP数据复制工具Distcp和cp比较

来源:互联网 发布:java如何查内存泄露 编辑:程序博客网 时间:2024/05/25 19:57

HADOOP数据复制工具Distcp和cp比较

 

1、工具描述

DistCp(分布式拷贝)是用于大规模集群内部和集群之间拷贝的工具。它使用Map/Reduce

实现文件分发,错误处理和恢复,以及报告生成。 它把文件和目录的列表作为map任务的输入,每个任务会完成源列表中部分文件的拷贝。 由于使用了Map/Reduce方法,这个工具在语义和执行上都会有特殊的地方。

Cp是一个hadoop 文件系统shell命令,用来复制源文件或目录到目的目录。

 

2、共同点

都可以复制HDFS系统的文件或目录到目的目录。

 

3、区别

cp命令是单进程,distcp是多进程,使用mapReduce进行分布式复制。

 

4、性能测试对比

 

数据量

cp执行时间

cp复制速率

Distcp执行时间

Distcp复制速率

1G

 

 

 

 

10G

 

 

 

 

100G

 

 

 

 

 

5、附录

cp详细用法

[hadoop@DEV-CentOS66-007 hadoop]$hadoop dfs -help cp

hadoop dfs -cp [-f] [-p | -p[topax]]<src> ... <dst> :

Copy files that match the file pattern<src> to a destination.  Whencopying

 multiple files, the destination must be a directory.

Passing -p preserves status[topax](timestamps, ownership, permission, ACLs, XAttr). If -p is specified  with no <arg>, then preserves timestamps,ownership, permission. If -pa is specified, then preserves permission also because ACL is a super-setof  permission.

Passing -f overwrites the destinationif it already exists. raw  namespaceextended attributes are preserved if (1) they are supported (HDFS  only) and, (2) all of the source and targetpathnames are in the /.reserved/raw hierarchy. raw namespace xattr preservation is determined solely by thepresence  (or absence) of the/.reserved/raw prefix and not by the -p option.

 

选项说明

标识

描述

备注

-f

选项将覆盖目标

覆盖目标,如果它已经存在。

-p

选项将保留文件属性(时间戳、所有权、许可、ACL、XAttr)。

如果P是无参数指定,然后保存时间戳,所有权,许可。如果指定PA,则保留权限,因为ACL是超级权限集。

<src>

源文件或目录

可以指定多个源文件或目录

<dst>

目的目录

最后一个参数是目的目录

 

distcp详细用法

[hadoop@DEV-CentOS66-007 hadoop]$ hadoop distcp

usage: distcp OPTIONS [source_path...] <target_path>

   OPTIONS

 -append                Reuse existing data in targetfiles and append new

                        data to them ifpossible

 -async                 Should distcp execution beblocking

 -atomic                Commit all changes or none

 -bandwidth<arg>       Specify bandwidth permap in MB

 -delete                Delete from target, filesmissing in source

 -diff <arg>            Use snapshot diff report toidentify the

                        difference between sourceand target

 -f <arg>               List of files that need to becopied

 -filelimit<arg>       (Deprecated!) Limitnumber of files copied to <= n

 -i                     Ignore failures duringcopy

 -log <arg>             Folder on DFS where distcp executionlogs are

                        saved

 -m <arg>               Max number of concurrent maps touse for copy

 -mapredSslConf<arg>   Configuration for sslconfig file, to use with

                        hftps://

 -overwrite             Choose to overwrite target filesunconditionally,

                        even if they exist.

 -p <arg>               preserve status(rbugpcaxt)(replication,

                        block-size, user,group, permission,

                        checksum-type, ACL, XATTR,timestamps). If -p is

                        specified with no<arg>, then preserves

                        replication, blocksize, user, group, permission,

                        checksum type andtimestamps. raw.* xattrs are

                        preserved when both thesource and destination

                        paths are in the/.reserved/raw hierarchy (HDFS

                        only). raw.*xattrpreservation is independent of

                        the -p flag. Refer tothe DistCp documentation for

                        more details.

 -sizelimit<arg>       (Deprecated!) Limitnumber of files copied to <= n

                        bytes

 -skipcrccheck          Whether to skip CRC checks betweensource and

                       target paths.

 -strategy<arg>        Copy strategy to use.Default is dividing work

                        based on file sizes

 -tmp <arg>             Intermediate work path to be usedfor atomic

                        commit

 -update                Update target, copying onlymissingfiles or

                        directories

 

选项说明

标识

描述

备注

-p[rbugp]

Preserve
  r: replication number
  b: block size
  u: user
  g: group
  p: permission

修改次数不会被保留。并且当指定 -update 时,更新的状态会 被同步,除非文件大小不同(比如文件被重新创建)。

-i

忽略失败

就像在 附录中提到的,这个选项会比默认情况提供关于拷贝的更精确的统计, 同时它还将保留失败拷贝操作的日志,这些日志信息可以用于调试。最后,如果一个map失败了,但并没完成所有分块任务的尝试,这不会导致整个作业的失败。

-log <logdir>

记录日志到 <logdir>

DistCp为每个文件的每次尝试拷贝操作都记录日志,并把日志作为map的输出。 如果一个map失败了,当重新执行时这个日志不会被保留。

-m <num_maps>

同时拷贝的最大数目

指定了拷贝数据时map的数目。请注意并不是map数越多吞吐量越大。

-overwrite

覆盖目标

如果一个map失败并且没有使用-i选项,不仅仅那些拷贝失败的文件,这个分块任务中的所有文件都会被重新拷贝。 就像下面提到的,它会改变生成目标路径的语义,所以 用户要小心使用这个选项。

-update

如果源和目标的大小不一样则进行覆盖

像之前提到的,这不是"同步"操作。 执行覆盖的唯一标准是源文件和目标文件大小是否相同;如果不同,则源文件替换目标文件。 像 下面提到的,它也改变生成目标路径的语义, 用户使用要小心。

-f <urilist_uri>

使用<urilist_uri> 作为源文件列表

这等价于把所有文件名列在命令行中。 urilist_uri 列表应该是完整合法的URI。

 

 

原创粉丝点击