如何让你的映射器写在hadoop的本地文件系统上 [英] How to make your mapper write on local file system in hadoop

查看:130
本文介绍了如何让你的映射器写在hadoop的本地文件系统上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望编写一个文件并通过m MapReduce代码在本地文件系统中创建一个目录。另外,如果我在作业执行期间在工作目录中创建一个目录,那么在清理之前如何将其移动到本地文件系统中。

由于您的映射器在集群中的某些机器上运行,当然您可以使用基本的Java文件操作来编写文件。您可以使用org.apache.hadoop.hdfs.DFSClient访问HDFS上的任何文件以复制到本地文件(我建议您在HDFS中复制并在作业完成后从其中获取任何文件)。



当然,你的本地文件将在本地客户端机器上(我假设单独的机器),所以需要像NFS这样的东西来让你的书面文件可用任何客户。小心concurreny问题。


I wish to write a file and create a directory in my local file system through m MapReduce code. Also if I create a directory in the working directory during the job execution, how can I move it to my local file system before the cleanup.

解决方案

As your mapper runs on some/any machine in your cluster, of course you can use basic Java file operations to write files. You can use org.apache.hadoop.hdfs.DFSClient to access any files on the HDFS to copy to a local file (I'd suggest you copy inside the HDFS and fetch any files from it after the jobs are finished).

Of course your local files will be local to the client-machine (I assume separate machines), so something like NFS will be needed to let the written files be available to you on any client. Watch out for concurreny problems.

这篇关于如何让你的映射器写在hadoop的本地文件系统上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆