hadoop distcp 参数详解

distcp 是一个用于数据复制的工具,它可以将数据从一个 Hadoop 集群复制到另一个 Hadoop 集群。

Usage: hadoop distcp [OPTIONS] <srcurl> <desturl>
OPTIONS:
  -p[rbugpcax]                 Preserve status (rbugpcax)
                               r: replication number
                               b: block size
                               u: user
                               g: group
                               p: permission
                               c: checksum type
                               a: ACLs
                               x: xattr
  -i,--ignore-failures         Ignore failures during copy
  -log <logdir>                Write logs to <logdir>/distcp.log
  -m <num_maps>                Maximum number of simultaneous copies
  -bandwidth <bandwidth>       Specify bandwidth to use when copying data
  -update                      Update target files when source is newer
  -overwrite                   Overwrite target files unconditionally
  -delete                      Delete the files existing in the target but not in the source
  -diff <snapshot> <snapshot>  Compute difference between two snapshots
  -skipcrccheck                Skip CRC checking when source and destination checksums exist
  -atomic                      Commit all changes or none
  -filters <filtersfile>       Filter files and directories to be copied
  -mapred <conf>               Use given mapred-site.xml for map-reduce job
  -pb <size-in-bytes>          Size of internal buffer in bytes
  -simulate                    Do everything except actually copying the files
  -async                       Use asynchronous version for file system operations
  -direct                      Use direct read and write
  -mapreduce-job-name <name>   Specify mapreduce job name

以下是 distcp 命令的所有参数说明:

  • srcurl: 指定数据源的 Hadoop URL,例如 hdfs://hostname:port/path/to/dir
  • desturl: 指定目的地的 Hadoop URL,例如 hdfs://hostname:port/path/to/dest.
  • -p: 用于指定需要保留哪些文件属性信息。可选值包括 r (副本数)、b (块大小)、u (用户)、g (用户组)、p (权限)、c (校验码类型)、a (ACL)、x (xattr)。例如,指定 -prug 参数,表示需要保留复制文件的副本数、用户、组和权限信息。
  • -i, --ignore-failures: 用于忽略复制过程中的错误,当出现错误时继续复制其他文件。
  • -log <logdir>: 用于指定日志文件的输出路径。例如,-log /tmp/distcp 指定将日志输出到 /tmp/distcp/distcp.log 文件中。
  • -m <num_maps>: 用于指定并发复制任务数量。可以通过指定大于 1 的值来加快复制速度。默认值为 20。
  • -bandwidth <bandwidth>: 用于限制数据传输的带宽。可以通过指定 来避免过度占用网络带宽。
  • -update: 用于在目标端只更新新的文件和文件夹,避免重复复制已经存在的文件。启用此选项可以加速数据传输。
  • -overwrite: 用于覆盖目标端的文件。启用此选项后,如果目标端存在与源端相同的文件,则会被覆盖。
  • -delete: 用于删除目标端中与源端不同的文件和目录。
  • -diff <snapshot> <snapshot>: 用于计算两个 HDFS 中不同的文件和目录。其中, 为在 Namenode 中创建的快照名称。
  • -skipcrccheck: 用于跳过源和目标的 CRC 检查。启用此选项可以加快复制速度,但会降低数据可靠性。
  • -atomic: 用于在所有的目标端操作完成或者出现错误的情况下进行数据复制。如果出现错误,distcp 会回滚之前的操作。
  • -filters <filtersfile>: 用于指定包含过滤规则的文件路径。过滤器文件是一个文本文件,其中每行包含一个正则表达式或一个文件路径,用于控制复制的文件范围。
  • -mapred <conf>: 用于指定 distcp 使用的 MapReduce 配置文件,如果不指定则使用默认的 Hadoop 配置。可以在此处指定例如 -D mapreduce.job.reduce.slowstart.completedmaps=0.5 等特定的配置选项。
  • -pb <size-in-bytes>: 用于指定内部缓冲区的大小。默认大小为 4 MB。
  • -simulate: 用于模拟复制操作,而不是实际进行复制。如果需要测试 distcp 的性能,可以使用此选项。
  • -async: 用于启用异步文件系统操作。启用此选项可以提高复制效率,但可能会降低数据可靠性。
  • -direct: 用于启用 NIO 直接缓冲模式进行文件 I/O。启用此选项可以提高复制效率。
posted @   蛇啊蛇啊  阅读(1723)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
点击右上角即可分享
微信分享提示