



全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Hadoop Streaming 实战 文件分发与打包 分类 hadoop2011 05 06 14 56432 人阅读评论 0 收藏举报 如果程序运行所需要的可执行文件 脚本或者配置文件在 Hadoop 集群的计算节点上不存 在 则首先需要将这些文件分发到集群上才能成功进行计算 Hadoop 提供了自动分发文件和压缩包的机制 只需要在启动 Streaming 作业时配置相应 的参数 1 file 将本地文件分发到计算结点 2 cacheFile 文件已经存放在 HDFS 中 希望计算时在每个计算节点上将文件当作本地 文件处理 3 cacheArchive 将存放在 HDFS 中的压缩包分发并解压 file 实战实战 使用使用 file 分发本地可执行文件和其他文件分发本地可执行文件和其他文件 a 待计算的数据放入 hdfs hadoop fs put localfile user hadoop hadoopfile b 编写 map reduce 脚本 记得给脚本加可执行权限 mapper sh view plaincopy to clipboardprint 1 bin sh 2 wc l bin sh wc l reducer sh view plaincopy to clipboardprint 1 bin sh 2 a 0 3 while read i 4 do 5 let a i 6 done 7 echo a bin sh a 0 while read i do let a i done echo a hello txt 文件内容 hello world c 运行 hadoop streaming input user hadoop hadoopfile output user hadoop result mapper mapper sh reducer reducer sh file mapper sh file reducer sh file hello txt jobconf mapred reduce tasks 1 jobconf mapre job name sum test d 查看结果 hadoop fs cat user hadoop result part 00000 cacheFile 实战实战 a 待计算的数据和文件放入 hdfs hadoop fs put hello txt user hadoop b 运行命令 mapper sh 和 reducer sh 脚本内容同上 hadoop streaming input user hadoop hadoopfile output user hadoop result mapper mapper sh reducer reducer sh file mapper sh file reducer sh cacheFilehdfs host port user hadoop hello txt hello txt jobconf mapred reduce tasks 1 jobconf mapre job name sum test 可以通过配置文件 hadoop site xml 中的 fs default name 配置参数的值得到文件所在的 host 和 port c 查看结果 hadoop fs cat user hadoop result part 00000 cacheArchive 实战实战 a 创建一个目录 test 目录中包含文件 mapper txt reducer hello txt 修改 mapper sh view plaincopy to clipboardprint 1 bin sh 2 a wc l 3 使用参数 4 b wc l 1 awk print 1 5 let c a b 6 echo c bin sh a wc l 使用参数 b wc l 1 awk print 1 let c a b echo c b 压缩文件夹并将压缩文件放入 hdfs cd test tar zcvf test tar gz hadoop fs put test tar gz user hadoop test c 运行命令 hadoop streaming input user hadoop hadoopfile output user hadoop result mapper test mapper sh test hello txt reducer test reducer sh cacheArchive hdfs host port user hadoop test test tar gz test jobconf mapred reduce tasks 1 jobconf mapre job name sum test d 查看结果 hadoop fs cat user hadoop result part 00000 首先将本地 test 目录中的所有文件和目录打包压缩 然后上传到 HDFS 中 启动 streaming 任务时使用 cacheArchive 选项将 test tar gz 分发到计算节点并解压到 test 目录 然后在当前工作目录创建到 test 目录的链接 mapper 选项指定为 map
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 钻井协作工节假日前安全考核试卷含答案
- 幼儿园后勤管理会议讲话稿
- 关于实验教学总结范文合集5篇
- 炭素浸渍工节假日前安全考核试卷含答案
- 海水鱼类养殖工节假日前安全考核试卷含答案
- 文秘人员工作技能提升培训教材与实操案例
- 关于五年级五单元的作文300字十篇
- 建筑管桩施工质量管理方案
- 肥料配方师节假日前安全考核试卷含答案
- 水工监测工国庆节后复工安全考核试卷含答案
- 120救护车仪器设备理论考核试题(含答案)
- 胸痛教学查房课件
- 开贷款中介公司策划方案
- 吉林省榆树一中五校联考2025届高二化学第二学期期末教学质量检测试题含解析
- 红十字三献知识培训课件
- 排球教学论文
- 《小学教师专业发展》课件-第二章 教师是如何发展的
- 心内科患者饮食护理要点
- 商业保洁服务合同协议书
- 解除市场经营协议书
- 育苗协议书范本
评论
0/150
提交评论