Nutch2.1分布式抓取

心中永远的正能量 2014-01-25

1准备环境:Hadoop集群、java、mysql数据库,代码可以在eclipse中运行,可以单机模式下插入数据到mysql数据库。

2修改配置文件nutch-site.xml:

<property>

  <name>plugin.folders</name>

  <value>./plugins</value>

  <description>Directories where nutch plugins are located.  Each

  element may be a relative or absolute path.  If absolute, it is used

  as is.  If relative, it is searched for on the classpath.</description>

</property>

在eclipse中选中buil.xml,run as ant,运行runtime,运行成功会产生文件夹runtime。

3 把runtime文件夹上传到hadoop集群中的master服务器(没有验证其他服务器是不是可以),我上传之后的位置是:/home/hadoop/nutch/runtime,设置环境变量:

在/etc/profile中:export NUTCH_HOME=/home/hadoop/nutch/runtime/local  source /etc/profile使得修改起作用。

4应该是把url种子文件上传到hadoop。我的种子文件始终没有成功,这一步略过。

5在/home/hadoop/nutch/runtime/deploy目录下运行:

./bin/nutch crawl  -dir crawl -depth 2 -threads 4 -topN 50

一点心得:nutch2之后不需要把配置文件(conf)分发到集群中的每台机器,但是修改配置文件以后需要重新用ant打包,配置才能生效。

Nutch的详细介绍:请点这里
Nutch的下载地址:请点这里

相关阅读

相关推荐

leshem / 0评论 2010-06-05