hadoop distcp 命令

来源:互联网 发布:淘宝客服聊天用语 编辑:程序博客网 时间:2024/05/31 18:32

实例:

hadoop distcp -ip -overwrite -m 80 "hdfs://${cluster_upload}/${biz}/${name}/ds=${date}" "hdfs://${cluster_95}/database/${biz}/${name}/ds=${date}"

hadoop distcp -overwrite -delete -i dir1 dir2


distcp 命令是用于集群内部或者集群之间拷贝数据的常用命令。

顾名思义: dist即分布式, 分布式拷贝是也。

hadoop distcp [选项]  src_url  dest_url  

常用选项

-m 表示启用多少map

-delete:删除已经存在的目标文件,不会删除源文件。这个删除是通过FS Shell实现的。所以如果垃圾回收机制启动的话,删除的目标文件会进入trash。
-i:忽略失败。这个选项会比默认情况提供关于拷贝的更精确的统计, 同时它还将保留失败拷贝操作的日志,这些日志信息可以用于调试。最后,如果一个map失败了,但并没完成所有分块任务的尝试,这不会导致整个作业的失败。
-overwrite:覆盖目标。如果一个map失败并且没有使用-i选项,不仅仅那些拷贝失败的文件,这个分块任务中的所有文件都会被重新拷贝。所以这就是为什么要使用-i参数。


新版本可以指定不同集群之间的拷贝, 

1. 指定不同集群的用户名密码

   distcp -m 300 -su <user,paswd>  -du <user,paswd> src_url dest_url  

2. 本地hadoop客户端需要设置hadoop_site.xml 中的各种信息 fs.default.name 

    目前猜测是因为distcp是要启动map任务的所以需要知道namenode, jobtracker等信息。


其他选项:

-p[rbugp]       Preserve status
                       r: replication number
                       b: block size
                       u: user
                       g: group
                       p: permission
                       -p alone is equivalent to -prbugp
-i                     Ignore failures
-log <logdir>          Write logs to <logdir>
-m <num_maps>          Maximum number of simultaneous copies
-overwrite             Overwrite destination
-update                Overwrite if src size different from dst size
-f <urilist_uri>       Use list at <urilist_uri> as src list
-filelimit <n>         Limit the total number of files to be <= n
-sizelimit <n>         Limit the total size to be <= n bytes
-delete                Delete the files existing in the dst but not in src
-mapredSslConf <f>     Filename of SSL configuration for mapper task

关于distcp的详细内容详见官方地址:http://hadoop.apache.org/common/docs/r0.20.0/distcp.html




原创粉丝点击