免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2390 | 回复: 0

[其他] 配置Disco——基于erlang的map-reduce架构 [复制链接]

论坛徽章:
0
发表于 2009-07-07 08:33 |显示全部楼层
配置Disco——基于erlang的map-reduce架构
   
   
Disco是一套轻量的Map-Reduce系统,其核心部分由并行性能很高的Erlang语言开发,其外部编程接口为易于编程的Python
语言。Disco可以实现在集群和多核计算机上的部属,并可以部署在Amazon
EC2上。下面我们将介绍一下如何在Ubuntu系统上配置Disco系统。
Disco可以在其官方网站(
http://discoproject.org/
)上下载,目前的最高版本为0.2(2009.4.7发布)。我在Ubuntu 8.10和9.04两个版本的系统上对disco进行了配置。过程如下:
1.安装必要的软件包
Disco依赖于如下的软件包,我们需要首先系统上安装完成:
SSH daemon and client  网址
http://www.openssh.com/
,可sudo apt-get install ssh
Erlang/OTP R12B or newer  网址
http://www.erlang.org/
,可sudo apt-get install erlang
Lighttpd 1.4.17 or newer  网址
http://lighttpd.net/
,可sudo apt-get install lighttpd
Python 2.4 or newer  网址
http://www.python.org/
,可sudo apt-get install python
Python setuptools  网址
http://pypi.python.org/pypi/setuptools
,可sudo apt-get install python-setuptools
cJSON module for Python  网址
http://pypi.python.org/pypi/python-cjson
,可sudo apt-get install python-cjson
2.编译和安装Disco
编译Disco很简单,只需要将Disco解压后在目录中直接 make 就可以,如果需要指定一个安装路径,可以用make
install
DESTDIR=***,将安装路径指定到***所代替的地址。如果需要在集群上来运行Disco,那么需要在集群的每一台机器上都配置好Disco。
3.配置Disco的运行环境
我们首先完成Disco在单机上的配置。
1)
我们需要让disco用户在SSH时可以不需要密码登录
假设节点上没有有效的ssh-key,可以通过下面的命令创建一个:
ssh-keygen -N '' -f ~/.ssh/id_dsa
在单机上或者共享存储的机群上,可以通过下面的命令配置:
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
配置完成后,可以通过下面的命令进行测试,如果不需要登录密码说明配置成功:
ssh localhost erl
2)
我们把Disco的安装路径称作$DISCOHOME$。
然后,我们需要在PYTHONPATH中增加$DISCOHOME$/pydisco,$DISCOHOME$/pydisco/disco,$DISCOHOME$/util,$DISCOHOME$/node/disconode等路径。
3)
启动Disco。
我们通过下面的方法分别在单机上启动master和node节点的disco进程。
conf/start-master
conf/start-node
需要注意的是,最好在执行这两个命令关闭之前启动的beam和lighttpd进程:
sudo killall -9 beam
sudo killall -9 lighttpd
4)
在浏览器中打开 http://localhost:7000 并且configure中增加可用的节点数(比如设定Nodes为localhost,Max Workers为2),并保存。
5)
通过以上的步骤,对于Disco设置基本完成,我们可以编写一个程序来测试Disco,比如网站上的统计词频的范例wordcount.py,其代码如下:
from disco.core import Disco, result_iterator
import disco
import sys
def fun_map(e, params):
    return [(w, 1) for w in e.split()]
def fun_reduce(iter, out, params):
    s = {}
    for w, f in iter:
        s[w] = s.get(w, 0) + int(f)
    for w, f in s.iteritems():
        out.add(w, f)
inputAddress = ["http://discoproject.org/chekhov.txt"]
results = disco.job(sys.argv[1], name = "wordcount",
                input = inputAddress,
                map = fun_map,
                reduce = fun_reduce,
                nr_reduces = 1,
                sort = False)
for word, frequency in result_iterator(results):
    print word,frequency
然后,运行python wordcount.py http://localhost:7000运行程序就可以,可以从http://localhost:7000来查看程序的运行状况。
更多的问题,可以参阅
http://discoproject.org/doc/start/troubleshoot.html
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/16651/showart_1987855.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP