hadoop streaming部分问题总结
来源:
https://hadoop.apache.org/docs/r1.2.1/streaming.html#Generic+Command+Options
文档还是要好好看,中间遇到的好多问题文档中都有。之前看的时候没有感觉,等遇到了问题再来看,就知道是啥了。
============================================================
一、options
hadoop streaming有两种参数:Generic Command Options和Streaming Command Options。
注意:genericOptions要求必须放在streamingOptions前面。如:
bin/hadoop command [genericOptions] [streamingOptions]
Generic Command Options
Parameter | Optional/Required | Description |
---|---|---|
-conf configuration_file | Optional | Specify an application configuration file |
-D property=value | Optional | Use value for given property |
-fs host:port or local | Optional | Specify a namenode |
-jt host:port or local | Optional | Specify a job tracker |
-files | Optional | Specify comma-separated files to be copied to the Map/Reduce cluster |
-libjars | Optional | Specify comma-separated jar files to include in the classpath |
-archives | Optional | Specify comma-separated archives to be unarchived on the compute machines |
Streaming Command Options
Parameter | Optional/Required | Description |
---|---|---|
-input directoryname or filename | Required | Input location for mapper |
-output directoryname | Required | Output location for reducer |
-mapper executable or JavaClassName | Required | Mapper executable |
-reducer executable or JavaClassName | Required | Reducer executable |
-file filename | Optional | Make the mapper, reducer, or combiner executable available locally on the compute nodes |
-inputformat JavaClassName | Optional | Class you supply should return key/value pairs of Text class. If not specified, TextInputFormat is used as the default |
-outputformat JavaClassName | Optional | Class you supply should take key/value pairs of Text class. If not specified, TextOutputformat is used as the default |
-partitioner JavaClassName | Optional | Class that determines which reduce a key is sent to |
-combiner streamingCommand or JavaClassName | Optional | Combiner executable for map output |
-cmdenv name=value | Optional | Pass environment variable to streaming commands |
-inputreader | Optional | For backwards-compatibility: specifies a record reader class (instead of an input format class) |
-verbose | Optional | Verbose output |
-lazyOutput | Optional | Create output lazily. For example, if the output format is based on FileOutputFormat, the output file is created only on the first call to output.collect (or Context.write) |
-numReduceTasks | Optional | Specify the number of reducers |
-mapdebug | Optional | Script to call when map task fails |
-reducedebug | Optional | Script to call when reduce task fails |
注意:
1, genericoption中的-files参数和streamingoptions中的-file参数。
前者为可以放多个,中间用逗号分隔,并且可以放hdfs files的地址。后者是从本地往hadoop执行目录上传文件。
使用的时候,-files需要放到streamingoptions(如:-input, -output等)前面。
2. cmdenv参数可以设定需要的环境变量
-cmdenv EXAMPLE_DIR=/home/example/dictionaries/
二、使用hdfs files地址
先把数据文件上传的hdfs上,之后可以直接使用。
使用参数:
-files hdfs://host:fs_port/user/testfile.txt
注意:
1. host:fs_port可以从/usr/local/hadoop/etc/hadoop/core-site.xml中,找到fs.defaultFS对应的value即可。
2. 使用的时候,直接在对应的mapper.py中,使用open("testfile.txt")即可。hadoop会创建一个连接,指向对应的文件。( Hadoop automatically creates a symlink named testfile.txt in the current working directory of the tasks. This symlink points to the local copy of testfile.txt.)
三、"No space left on device" error?
这是因为hadoop streaming中,会把需要的-file文件打成jar包上传,如果文件很大,jar包也很大。jar包默认是放在/tmp目录下。如果/tmp目录空间不够,则会报该错误。
更改目录命令:
-D stream.tmpdir=/export/bigspace/...
四、在mapper.py中获取设置的参数
加入设置:
-D mapred.reduce.tasks=1
如何在mapper.py中获取该参数:
直接把对应的参数名中"."换成下划线"_"即可获得。
reducer_tasks = os.getenv(“mapred_reduce_tasks')
hadoop streaming部分问题总结相关推荐
- Hadoop Streaming框架使用(三)
前两篇文章介绍了Hadoop Streaming框架的使用方法.由于篇幅所限,并没有介绍其中的高级使用方法,但是有一些用法还是相当常见的.今天对一些高级用法进行一个简单的说明,希望能给大家一些启发. ...
- Hadoop Streaming框架使用(一)
Streaming简介 link:http://www.cnblogs.com/luchen927/archive/2012/01/16/2323448.html Streaming框架允许任何程 ...
- Hadoop Streaming 编程
1.概述 Hadoop Streaming是Hadoop提供的一个编程工具,它允许用户使用任何可执行文件或者脚本文件作为Mapper和Reducer,例如: 采用shell脚本语言中的一些命令作为ma ...
- Hadoop Streaming编程实例
Hadoop Streaming是Hadoop提供的多语言编程工具,通过该工具,用户可采用任何语言编写MapReduce程序,本文将介绍几个Hadoop Streaming编程实例,大家可重点从以下几 ...
- Hadoop详解(九):Hadoop Streaming和Pipes原理和实现
为了保证编程接口的通用性,Hadoop提供了Streaming和Pipes编程框架和接口,Streaming编程框架通过标准的输入/输出作为媒介来和Hadoop框架交换数据,因此任何可以操作的标准输入 ...
- Hadoop streaming: Exception in thread main java.io.IOException: No space left on device
在使用Hadoop streaming时,遇到报错如标题: packageJobJar: [mapper_sim.py, reducer_sim.py, XXX files, /tmp/hadoop- ...
- 利用Hadoop Streaming处理二进制格式文件
Hadoop Streaming是Hadoop提供的多语言编程工具,用户可以使用自己擅长的编程语言(比如python.php或C#等)编写Mapper和Reducer处理文本数据.Hadoop Str ...
- Hadoop Streaming高级编程
1. 概要 本文主要介绍了Hadoop Streaming的一些高级编程技巧,包括,怎样在mapredue作业中定制输出输出格式?怎样向mapreduce作业中传递参数?怎么在mapreduce作业中 ...
- Hadoop Streaming
Hadoop Streaming Hadoop Streaming Hadoop Streaming Streaming工作原理 将文件打包到提交的作业中 Streaming选 ...
最新文章
- 学习笔记---取得枚举项的2种方法: Enum.GetValues()-Array.GetValue()和Enum.GetNames()-Enum.Parse()...
- 手动脱Mole Box壳实战总结
- 判断字符串是不是application/x-www-form-urlencoded字符串(URL编码格式的字符串)
- c++中关于字符串的读入——cin、getline、get、gtes(查询+思考+总结)
- html文档主体的根标签,2 HTML简介标签嵌套和并列关系文档声明
- swift int转string_Swift集合类型协议浅析(下)
- 4月还完债务,“真还传”大结局?罗永浩回应:纯属造谣...
- 测试面试题集-3.生活物品测试:行李箱、电梯、洗衣机
- 高性能计算GPU解决方案系列课程一--高性能计算简介
- 笨方法学Python3 习题6
- 电力负荷预测数据集(2018.1-2020.12,间隔15min,10w多条,含温度、风速等天气因素特征)
- C语言回调函数详解(全网最全)
- @property详细解读
- no python interpreter selected_报No Python interpreter selected错误怎么办
- 歪门邪道之解决首屏图片加载闪烁问题
- 优酷视频kux格式转换为MP4的两种技巧
- “风雨如晦,鸡鸣不已。既见君子,云胡不喜。” 王者荣耀李白王昭君情侣头像故事...
- 单点登录SSO:图示和讲解
- android 垂直水平居中对齐,Android中RelativeLayout的字符水平(垂直居中)对齐
- 女神节礼物推荐,2022年女神节送女生什么礼物好
热门文章
- 算法提高课-搜索-Flood fill算法-AcWing 1106. 山峰和山谷:flood fill、bfs
- 计算机组成原理精品课程申报书,【计算机科学与技术专业】【毕业设计】计算机组成原理精品课程平台的设计与实现...
- Android实训日志:基于外部存储的音乐播放器V06
- python动态参数_python动态参数
- git stage 暂存_什么是Git?下载和安装Git
- android中px单位,android中像素单位dp、px、pt、sp的比较
- oracle sga pga mysql_Oracle 体系结构 SGA 和PGA 总结
- Shell中的循环语句
- linux 指定时间加3天,Linux系统的定时任务和延时任务
- 帧布局 (FrameLayout)