【dumbo】【hadoop】使用dumbo开发hadoop streaming程序
2013-06-05 04:43
375 查看
转自:http://www.cnblogs.com/flying5/archive/2011/09/07/2169574.html1. dumbo的官网:https://github.com/klbostee/dumbo/ wiki: https://github.com/klbostee/dumbo/wiki2. 安装配置 详见wiki:https://github.com/klbostee/dumbo/wiki/Building-and-installing 解压从网站下载下来的源码到dumbo文件夹,执行如下命令就可以了
3. 例子程序 使用dumbo开发程序来统计apache的访问日志中最多的几个ip地址 apache日志格式如下:
ipcount.py程序如下:
运行:
可以看到在本机上执行的结果。 在hadoop上运行:viewsourceprint?
wget - O ez_setup.py http: / / peak.telecommunity.com / dist / ez_setup.py |
python ez_setup.py dumbo |
[admin @search011 dumbotest]$ head -n3 access.log |
10.0 . 0.1 - - [ 02 /Nov/ 2010 : 10 : 15 : 52 + 0800 ] "GET /index/Back/task_updator.php?taskid=22870&sub_taskid=15&runhost=localhost&status=OK HTTP/1.0" 200 3 "-" "Wget/1.10.2 (Red Hat modified)" |
10.0 . 0.3 - - [ 02 /Nov/ 2010 : 10 : 15 : 52 + 0800 ] "GET /index/Back/task_updator.php?taskid=22870&sub_taskid=17&runhost=localhost&status=OK HTTP/1.0" 200 3 "-" "Wget/1.10.2 (Red Hat modified)" |
10.0 . 0.1 - - [ 02 /Nov/ 2010 : 10 : 15 : 53 + 0800 ] "GET /index/Back/task_updator.php?taskid=22870&sub_taskid=9&runhost=localhost&status=OK HTTP/1.0" 200 3 "-" "Wget/1.10.2 (Red Hat modified)" |
#!/bin/env python |
# cut -d ' ' -f 1 access.log | sort | uniq -c | sort -nr | head -n 5 |
def mapper(key, value): |
yield value.split( " " )[ 0 ], 1 |
def reducer(key, values): |
yield key, sum (values) |
if __name__ = = "__main__" : |
import dumbo |
dumbo.run(mapper, reducer, combiner = reducer) |
cut - d ' ' - f 1 access.log | sort | uniq - c | sort - nr | head - n 5 |
dumbo start ipcount.py - hadoop / home / admin / hadoop - libjar / home / admin / hadoop / contrib / streaming / hadoop - streaming - 0.20 . 2 - CDH3B4.jar - input / admin / input - output / admin / output |
相关文章推荐
- 使用dumbo开发hadoop streaming程序
- 使用dumbo开发hadoop streaming程序
- 使用python开发hadoop streaming程序及hadoop python网页抓取例子
- Hadoop实战-使用Eclipse开发Hadoop API程序(四)
- Eclipse中使用Hadoop集群模式开发配置及简单程序示例(Windows下)
- windows上使用eclipse远程连接hadoop进行程序开发没有权限访问问题
- 如何在windows上使用eclipse远程连接hadoop进行程序开发
- Hadoop学习笔记(九):如何在windows上使用eclipse远程连接hadoop进行程序开发
- Windows上使用Eclipse远程连接Hadoop进行程序开发
- 【hadoop】Hadoop学习笔记(九):如何在windows上使用eclipse远程连接hadoop进行程序开发
- 使用python+hadoop-streaming编写hadoop处理程序
- 如何在windows上使用eclipse远程连接hadoop进行程序开发
- windows上使用eclipse远程连接hadoop进行程序开发没有权限访问问题
- 如何使用eclipse开发hadoop程序
- 使用eclipse开发hadoop程序时,如何连接远程linux
- Windows下使用Eclipse开发Hadoop程序
- Win下使用Eclipse开发scala程序配置(基于Hadoop2.7.3集群)
- Eclipse中使用Hadoop伪分布模式开发配置及简单程序示例(Linux下)
- 借助hadoop streaming,使用C++编写MapReduce程序
- Hadoop-06-使用Eclipse开发HBase程序