1、下载相关软件,并解压

版本号如下:

(1)apache-nutch-2.2.1

(2) hbase-0.90.4

(3)solr-4.9.0

并解压至/usr/search

2、Nutch的配置

(1)vi /usr/search/apache-nutch-2.2.1/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>

(2)vi /usr/search/apache-nutch-2.2.1/ivy/ivy.xml

默认情况下,此语句被注释掉,将其注释符号去掉,使其生效。

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

(3)vi /usr/search/apache-nutch-2.2.1/conf/gora.properties

添加以下语句:

gora.datastore.default=org.apache.gora.hbase.store.HBaseStore

以上三个步骤指定了使用HBase来进行存储。

以下步骤才是构建基本Nutch的必要步骤。

(4)构建runtime

cd /usr/search/apache-nutch-2.2.1/

ant runtime

(5)验证Nutch安装完成

[root@jediael44 apache-nutch-2.2.1]# cd /usr/search/apache-nutch-2.2.1/runtime/local/bin/

[root@jediael44 bin]# ./nutch 

Usage: nutch COMMAND

where COMMAND is one of:

 inject         inject new urls into the database

 hostinject     creates or updates an existing host table from a text file

 generate       generate new batches to fetch from crawl db

 fetch          fetch URLs marked during generate

 parse          parse URLs marked during fetch

 updatedb       update web table after parsing

 updatehostdb   update host table after parsing

 readdb         read/dump records from page database

 readhostdb     display entries from the hostDB

 elasticindex   run the elasticsearch indexer

 solrindex      run the solr indexer on parsed batches

 solrdedup      remove duplicates from solr

 parsechecker   check the parser for a given url

 indexchecker   check the indexing filters for a given url

 plugin         load a plugin and run one of its classes main()

 nutchserver    run a (local) Nutch server on a user defined port

 junit          runs the given JUnit test

 or

 CLASSNAME      run the class named CLASSNAME

Most commands print help when invoked w/o parameters.

(6)vi /usr/search/apache-nutch-2.2.1/runtime/local/conf/nutch-site.xml 添加搜索任务

<property>
<name>http.agent.name</name>
<value>My Nutch Spider</value>
</property>

(7)创建seed.txt

cd /usr/search/apache-nutch-2.2.1/runtime/local/bin/

vi seed.txt

http://nutch.apache.org/

(8)修改网页过滤器  vi /usr/search/apache-nutch-2.2.1/conf/regex-urlfilter.txt

vi /usr/search/apache-nutch-2.2.1/conf/regex-urlfilter.txt

# accept anything else

+.

修改为

# accept anything else

+^http://([a-z0-9]*\.)*nutch.apache.org/

(9)增加索引内容
默认情况下,schema.xml文件中的core及index-basic中的field才会被索引,为索引更多的field,可以通过以下方式添加。
修改nutch-default.xml,新增以下红色内容
<property>
  <name>plugin.includes</name>
 <value>protocol-http|urlfilter-regex|parse-(html|tika)|index-(basic|anchor)|urlnormalizer-(pass|regex|basic)|scoring-opic|index-anchor|index-more|languageidentifier|subcollection|feed|creativecommons|tld</value> 
 <description>Regular expression naming plugin directory names to
  include. Any plugin not matching this expression is excluded.
  In any case you need at least include the nutch-extensionpoints plugin. By
  default Nutch includes crawling just HTML and plain text via HTTP,
  and basic indexing and search plugins. In order to use HTTPS please enable
  protocol-httpclient, but be aware of possible intermittent problems with the
  underlying commons-httpclient library.
  </description>
</property>
或者可以在nutch-site.xml中添加plugin.includes属性,并将上述内容复制过去。注意,在nutch-site.xml中的属性会代替nutch-default.xml中的属性,因此必须将原有的属性也复制过去。

3、Hbase的配置

(1)vi /usr/search/hbase-0.90.4/conf/hbase-site.xml

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hbase.rootdir</name>
<value><Your path></value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value><Your path></value>
</property>
</configuration>

注:此步骤可不做。若不做,则使用hbase-default.xml(/usr/search/hbase-0.90.4/src/main/resources/hbase-default.xml)中的默认值。

默认值为:

  <property>
<name>hbase.rootdir</name>
<value>file:///tmp/hbase-${user.name}/hbase</value>
<description>The directory shared by region servers and into
which HBase persists. The URL should be 'fully-qualified'
to include the filesystem scheme. For example, to specify the
HDFS directory '/hbase' where the HDFS instance's namenode is
running at namenode.example.org on port 9000, set this value to:
hdfs://namenode.example.org:9000/hbase. By default HBase writes
into /tmp. Change this configuration else all data will be lost
on machine restart.
</description>
</property>

即默认情况下会放在/tmp目录,若机器重启,有可能数据丢失。

但是建议还是把这些属性做好配置,尤其是第二个关于zoopkeeper的,否则会导致各种问题。以下将目录配置在本地文件系统中。

<configuration>
<property>
<name>hbase.rootdir</name>
<value>file:///home/jediael/hbaserootdir</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>file:///home/jediael/hbasezookeeperdataDir</value>
</property> </configuration>

注意,若无前缀file://,则默认是hdfs://

但在0.90.4版本,默认还是本地文件系统。

4、Solr的配置

(1)覆盖solr的schema.xml文件。(对于solr4,应该使用schema-solr4.xml)

cp /usr/search/apache-nutch-2.2.1/conf/schema.xml /usr/search/solr-4.9.0/example/solr/collection1/conf/

(2)若使用solr3.6,则至此已经完成配置,但使用4.9,需要修改以下配置:

修改上述复制过来的schema.xml文件

删除:<filter class="solr.EnglishPorterFilterFactory" protected="protwords.txt" />

增加:<field name="_version_" type="long" indexed="true" stored="true"/>

5、启动抓取任务

(1)启动HBase

[root@jediael44 bin]# cd /usr/search/hbase-0.90.4/bin/

[root@jediael44 bin]# ./start-hbase.sh

(2)启动Solr

[root@jediael44 bin]# cd /usr/search/solr-4.9.0/example/

[root@jediael44 example]# java -jar start.jar

(3)启动Nutch,开始抓取任务

[root@jediael44 example]# cd /usr/search/apache-nutch-2.2.1/runtime/local/bin/

[root@jediael44 bin]# ./crawl seed.txt TestCrawl http://localhost:8983/solr 2

大功告成,任务开始执行。

关于上述过程的一些分析请见:

集成Nutch/Hbase/Solr构建搜索引擎之二:内容分析

http://blog.csdn.net/jediael_lu/article/details/37738569

使用crontab来设置Nutch的例行任务时,出现以下错误
JAVA_HOME is not set。
于是创建了一个脚本,用于执行抓取工作:
#!/bin/bash
export JAVA_HOME=/usr/java/jdk1.7.0_51
/opt/jediael/apache-nutch-2.2.1/runtime/local/bin/crawl /opt/jediael/apache-nutch-2.2.1/runtime/local/urls/ mainhttp://localhost:8080/solr/ 2 >> ~jediael/nutch.log
然后再配置例行任务
30 0,6,8,10,12,14,16,18,20,22 * * * bash /opt/jediael/apache-nutch-2.2.1/runtime/local/bin/myCrawl.sh

【Nutch2.2.1基础教程之2.1】集成Nutch/Hbase/Solr构建搜索引擎之一:安装及运行【单机环境】的更多相关文章

  1. 【Nutch2.2.1基础教程之2.2】集成Nutch/Hbase/Solr构建搜索引擎之二:内容分析

    请先参见"集成Nutch/Hbase/Solr构建搜索引擎之一:安装及运行",搭建测试环境 http://blog.csdn.net/jediael_lu/article/deta ...

  2. 【Nutch2.3基础教程】集成Nutch/Hadoop/Hbase/Solr构建搜索引擎:安装及运行【集群环境】

    1.下载相关软件,并解压 版本号如下: (1)apache-nutch-2.3 (2) hadoop-1.2.1 (3)hbase-0.92.1 (4)solr-4.9.0 并解压至/opt/jedi ...

  3. 【Nutch2.2.1基础教程之3】Nutch2.2.1配置文件

    nutch-site.xml 在nutch2.2.1中,有两份配置文件:nutch-default.xml与nutch-site.xml. 其中前者是nutch自带的默认属性,一般情况下不要修改. 如 ...

  4. 【Nutch2.2.1基础教程之3】Nutch2.2.1配置文件 分类: H3_NUTCH 2014-08-18 16:33 1376人阅读 评论(0) 收藏

    nutch-site.xml 在nutch2.2.1中,有两份配置文件:nutch-default.xml与nutch-site.xml. 其中前者是nutch自带的默认属性,一般情况下不要修改. 如 ...

  5. 【Nutch2.2.1基础教程之6】Nutch2.2.1抓取流程

    一.抓取流程概述 1.nutch抓取流程 当使用crawl命令进行抓取任务时,其基本流程步骤如下: (1)InjectorJob 开始第一个迭代 (2)GeneratorJob (3)FetcherJ ...

  6. 【Nutch2.2.1基础教程之1】nutch相关异常

    1.在任务一开始运行,注入Url时即出现以下错误. InjectorJob: Injecting urlDir: urls InjectorJob: Using class org.apache.go ...

  7. 【Nutch2.2.1基础教程之6】Nutch2.2.1抓取流程 分类: H3_NUTCH 2014-08-15 21:39 2530人阅读 评论(1) 收藏

    一.抓取流程概述 1.nutch抓取流程 当使用crawl命令进行抓取任务时,其基本流程步骤如下: (1)InjectorJob 开始第一个迭代 (2)GeneratorJob (3)FetcherJ ...

  8. 【Nutch2.2.1基础教程之1】nutch相关异常 分类: H3_NUTCH 2014-08-08 21:46 1549人阅读 评论(2) 收藏

    1.在任务一开始运行,注入Url时即出现以下错误. InjectorJob: Injecting urlDir: urls InjectorJob: Using class org.apache.go ...

  9. OpenVAS漏洞扫描基础教程之OpenVAS概述及安装及配置OpenVAS服务

    OpenVAS漏洞扫描基础教程之OpenVAS概述及安装及配置OpenVAS服务   1.  OpenVAS基础知识 OpenVAS(Open Vulnerability Assessment Sys ...

随机推荐

  1. MyEclipse java was started but returned exit code=-1

    java was started but returned exit code=-1 Vm指的是java虚拟机,默认你安装MyEclipse时会自带一个java虚拟机,Vm配置那一行换成你安装的jav ...

  2. php 序列化储存和转化 json_encode() json_decode($q,true)

    序列化是将变量转换为可保存或传输的字符串的过程:反序列化就是在适当的时候把这个字符串再转化成原来的变量使用.这两个过程结合起来,可以轻松地存储和传输数据,使程序更具维护性. 例如:当需要数据库只有一个 ...

  3. [TYVJ] P1017 冗余关系

    冗余关系 背景 Background 太原成成中学第3次模拟赛 第4题   描述 Description Mrs.Chen是一个很认真很称职的语文老师 ......所以,当她看到学生作文里的人物关系描 ...

  4. NOD32强制卸载工具使用方法【转】

    装了ESET NOD32又忘记密码了,无法卸载,怎么办? 以下转自官网:http://faq.eset.com.cn/index.php?pid=254 [适用产品:ESET NOD32 防病毒软件4 ...

  5. cf B. Resort

    http://codeforces.com/contest/350/problem/B 从旅馆开始倒着找到一个点它的出度>1的位置为止,比较长度大小,找到一个长度最大的即可. #include ...

  6. Delphi中ShellExecute使用详解(详细解释10种显示状态)

    有三个API函数可以运行可执行文件WinExec.ShellExecute和CreateProcess.1.CreateProcess因为使用复杂,比较少用.2.WinExec主要运行EXE文件.如: ...

  7. C语言---类型转换

    itoa 功 能:把一整数转换为字符串 用 法:char *itoa(int value, char *string, int radix); 详细解释:itoa是英文integer to array ...

  8. Shortest Word Distance 解答

    Question Given a list of words and two words word1 and word2, return the shortest distance between t ...

  9. JS帮你计算属相

        背景:一个人出生在2014年的正月初一,他的生肖到底是属蛇还是属马呢?这就要确定那一天才是一年的开始.是春节还是立春?每年的春节是正月初一,但是生肖必须是从立春日开始计算.春节是1912年孙中 ...

  10. JSTL解析——007——fmt标签库02

    各位亲们,近期事情比较多,没更新,come on! 1.<fmt:bundle>/<fmt:message>/<fmt:param>资源国际化标签 java中使用R ...