首页 技术 正文
技术 2022年11月15日
0 收藏 328 点赞 3,047 浏览 2095 个字

参考http://wiki.apache.org/nutch/RunNutchInEclipse

一、环境准备

1、下载nutch2.3源代码

wget http://mirror.bit.edu.cn/apache/nutch/2.3/apache-nutch-2.3-src.tar.gz

或者下载正在开发中的最新版本

 svn co https://svn.apache.org/repos/asf/nutch/branches/2.x

2、选择使用的数据库类型,以hbase为例

在conf/nutch-site.xml中增加以下属性:

<property>
<name>storage.data.store.class</name>
<value>org.apache.gora.hbase.store.HBaseStore</value>
<description>Default class for storing data</description>
</property>

3、在ivy/ivy.xml中增加与hbase相关的依赖项,此项本已存在,但被注释掉,将注释去掉即可

<dependency org="org.apache.gora" name="gora-hbase" rev="0.5" conf="*->default” />

注意,rev=0.5对应hbase0.94,rev=0.3对应hbase0.90.4

4、在nutch.xml中增加以下3个属性

<property>
<name>http.agent.name</name>
<value>My Nutch Spider</value>
</property>
<property>
<name>http.robots.agents</name>
<value>none</value>
</property>
<property>
<name>plugin.folders</name>
<value>/Users/liaoliuqing/0_Search/1_Nutch/1_Official/apache-nutch-2.3/build/plugins</value>
</property>

其中plugin.folders的值为$NUTCH_HOME/build/plugins

5、执行ant eclipse

二、导入project

1、导入project

2、在build path中,将apche-nutch-2.3/conf放到最上面,即点击top按键

三、运行程序

1、Run as —-> Run configuration,选择project与主类

2、填写参数

/Users/liaoliuqing/Downloads/seed.txt

-Dhadoop.log.dir=logs -Dhadoop.log.file=hadoop.log

3、点击run,输出结果如下:

InjectorJob: starting at 2015-01-28 16:27:43

InjectorJob: Injecting urlDir: /Users/liaoliuqing/Downloads/seed.txt

InjectorJob: Using class org.apache.gora.hbase.store.HBaseStore as the Gora storage class.

InjectorJob: total number of urls rejected by filters: 0

InjectorJob: total number of urls injected after normalization and filtering: 1

Injector: finished at 2015-01-28 16:27:47, elapsed: 00:00:04

注意,在运行程序前,本机需要先启动hbase。

4、查看hbase中的数据

hbase(main):003:0> scan 'webpage'
ROW COLUMN+CELL
com.163.www:http/ column=f:fi, timestamp=1422433667377, value=\x00'\x8D\x00
com.163.www:http/ column=f:ts, timestamp=1422433667377, value=\x00\x00\x01K/\xA7:\x14
com.163.www:http/ column=mk:_injmrk_, timestamp=1422433667377, value=y
com.163.www:http/ column=mk:dist, timestamp=1422433667377, value=0
com.163.www:http/ column=mtdt:_csh_, timestamp=1422433667377, value=?\x80\x00\x00
com.163.www:http/ column=s:s, timestamp=1422433667377, value=?\x80\x00\x00
1 row(s) in 0.2970 seconds
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,992
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,506
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,349
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,134
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,767
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,844