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

时间:2023-01-19 09:26:13

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

版本号如下:

(1)apache-nutch-2.3

(2) hadoop-1.2.1

(3)hbase-0.92.1

(4)solr-4.9.0

并解压至/opt/jediael。

若要下载最新的开发版本nutch,可以进行以下操作

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

2、安装hadoop1.2.1集群环境

见http://blog.csdn.net/jediael_lu/article/details/38926477

3、安装hbase0.92.1集群环境

见http://blog.csdn.net/jediael_lu/article/details/43086641

4、Nutch的配置

(1)vi /usr/search/apache-nutch-2.3/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>
<pre name="code" class="html"><property>
<name>http.agent.name</name>
<value>My Nutch Spider</value>
</property>

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

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

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

gora-hbase 0.5对应hbase0.94.12

根据需要修改hadoop的版本:

<dependency org="org.apache.hadoop" name="hadoop-core"  rev="1.2.1" conf="*->default”>
<dependency org="org.apache.hadoop" name="hadoop-test" rev="1.2.1" conf="test->default”>

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

添加以下语句:

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

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

(4)根据需要修改网页过滤器

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

vi /usr/search/apache-nutch-2.3/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,新增以下红色内容【或者只增加index-more】

<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中的属性,因此必须将原有的属性也复制过去。

(5)构建runtime

cd /usr/search/apache-nutch-2.3/

ant runtime

(6)验证Nutch安装完成

# cd /usr/search/apache-nutch-2.3/runtime/local/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.

(7)创建seed.txt

cd /usr/search/apache-nutch-2.3/runtime/deploy/bin/

vi seed.txt

http://nutch.apache.org/

hadoop fs -copyFromLocal seed.txt /

将seed.txt放到HDFS的根目录下。

(8)在运行过程中,会出现以下异常:

java.lang.RuntimeException: java.lang.ClassNotFoundException: org.apache.nutch.indexer.solr.SolrDeleteDuplicates$SolrInputFormat



原因未明。为使抓取能正常继续,先将crawl文件中的以下语句注释掉

    #echo "SOLR dedup -> $SOLRURL"
#__bin_nutch solrdedup $commonOptions $SOLRURL

以后找原因。

export CLASSPATH=$CLASSPATH:.....无效。

但使用local模式运行不会有以上的错误。

5、Solr的配置

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

cp /usr/search/apache-nutch-2.3/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"/>

或者使用tomcat来运行solr,见http://blog.csdn.net/jediael_lu/article/details/37908885。

6、启动抓取任务

(1)启动hadoop

#start-all.sh

(2)启动HBase

# ./start-hbase.sh

(3)启动Solr

[# cd /usr/search/solr-4.9.0/example/

# java -jar start.jar

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

将seed.txt复制到hdfs的根目录下。

# cd /usr/search/apache-nutch-2.3/runtime/deploy

# bin/crawl /seed.txt TestCrawl http://localhost:8583/solr 2

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

7、安装过程中可能出现的异常

异常一:No active index writer.

修改nutch-default.xml,在plugin.includes中增加indexer-solr。





异常二:ClassNotFoundException: org.apache.nutch.indexer.solr.SolrDeleteDuplicates$SolrInputFormat



在SolrDeleteDuplicates中的Job job = new Job(getConf(), "solrdedup");

后添加以下代码:

job.setJarByClass(SolrDeleteDuplicates.class);

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

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

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

使用crontab来设置Nutch的例行任务时,出现以下错误
JAVA_HOME is not set。

以及

Can't find Hadoop executable. Add HADOOP_HOME/bin to the path or run in local mode.
于是创建了一个脚本,用于执行抓取工作:
$ vi /opt/jediael/apache-nutch-2.3/runtime/deploy/bin/myCrawl.sh
#!/bin/bash
export JAVA_HOME=/usr/java/jdk1.7.0_51
export PATH=$PATH:/opt/jediael/hadoop-1.2.1/bin/
/opt/jediael/apache-nutch-2.3/runtime/deploy/bin/crawl /seed.txt `date +%h%d%H` http://master:8983/solr/ 2
然后再配置例行任务
0 0,9,12,15,19,21 * * * bash /opt/jediael/apache-nutch-2.3/runtime/deploy/bin/myCrawl.sh >> ~/nutch.log

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

  1. 【Nutch2&period;2&period;1基础教程之2&period;2】集成Nutch&sol;Hbase&sol;Solr构建搜索引擎之二:内容分析

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

  2. 【Nutch2&period;2&period;1基础教程之2&period;1】集成Nutch&sol;Hbase&sol;Solr构建搜索引擎之一:安装及运行【单机环境】

    1.下载相关软件,并解压 版本号如下: (1)apache-nutch-2.2.1 (2) hbase-0.90.4 (3)solr-4.9.0 并解压至/usr/search 2.Nutch的配置 ...

  3. hadoop 2&period;5&period;1单机安装部署伪集群

    环境:ubuntu 14.04 server 64版本 hadoop 2.5.1 jdk 1.6 部署的步骤主要参考了http://blog.csdn.net/greensurfer/article/ ...

  4. Envoy 基础教程:使用 Unix Domain Socket(UDS) 与上游集群通信

    Envoy Proxy 在大多数情况下都是作为 Sidecar 与应用部署在同一网络环境中,每个应用只需要与 Envoy(localhost)交互,不需要知道其他服务的地址.然而这并不是 Envoy ...

  5. Asp&period;net Core 使用Jenkins &plus; Dockor 实现持续集成、自动化部署(三):搭建jenkins集群环境

    写在前面 大家可以看到本文的配图,左边是jenkins单机环境,右边是jenkins集群.个中区别,不言而喻,形象生动. 前面我分别介绍了.net core 程序的多种部署方式(无绝对孰优孰劣): 1 ...

  6. Hadoop学习(一):完全分布式集群环境搭建

    1. 设置免密登录 (1) 新建普通用户hadoop:useradd hadoop(2) 在主节点master上生成密钥对,执行命令ssh-keygen -t rsa便会在home文件夹下生成 .ss ...

  7. Hadoop&plus;HBase&plus;ZooKeeper分布式集群环境搭建

    一.环境说明 集群环境至少需要3个节点(也就是3台服务器设备):1个Master,2个Slave,节点之间局域网连接,可以相互ping通,下面举例说明,配置节点IP分配如下: Hostname IP ...

  8. 基于Nutch&plus;Hadoop&plus;Hbase&plus;ElasticSearch的网络爬虫及搜索引擎

    基于Nutch+Hadoop+Hbase+ElasticSearch的网络爬虫及搜索引擎 网络爬虫架构在Nutch+Hadoop之上,是一个典型的分布式离线批量处理架构,有非常优异的吞吐量和抓取性能并 ...

  9. 基于HBase Hadoop 分布式集群环境下的MapReduce程序开发

    HBase分布式集群环境搭建成功后,连续4.5天实验客户端Map/Reduce程序开发,这方面的代码网上多得是,写个测试代码非常容易,可是真正运行起来可说是历经挫折.下面就是我最终调通并让程序在集群上 ...

随机推荐

  1. Java Web Cookie

    一.什么是cookie? 1.Cookie能使站点跟踪特定访问者的访问次数.最后访问时间和访问者进入站点的路径 2.Cookie能告诉在线广告商广告被点击的次数,从而可以更精确的投放广告 3.Cook ...

  2. servlet&amp&semi;jsp高级:第二部分

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  3. 网络图片下载缓存库SDWebImage的使用

    SDWebImage导入问题 最新的SDWebImage由于是基于ARC模式写的,如果创建的是非ARC醒目的童鞋们注意,导入文件夹之后,先添加ImageIO.framework,mapKit.fram ...

  4. JavaPersistenceWithHibernate第二版笔记-第五章-Mapping value types-001Mapping basic properties&lpar;&commat;Basic、&commat;Access、access&equals;&quot&semi;noop&quot&semi;、&commat;Formula、&commat;ColumnTransformer、&commat;Generated、 &commat;ColumnDefaul、&commat;Temporal、&commat;Enumerated&rpar;

    一.简介 在JPA中,默认所有属性都会persist,属性要属于以下3种情况,Hibernate在启动时会报错 1.java基本类型或包装类 2.有注解 @Embedded 3.有实现java.io. ...

  5. 恢复SD卡错删数据

           对于众多米粉来说,手机里存储的很多资料都非常宝贵,如果不小心删除了,想要重新收集这些资料就显得非常困难.有道是千金易得,数据无价,特别是一些珍贵照片之类的充满回忆的数据,丢失了甚至会抱憾 ...

  6. 黑马程序员&lowbar;Java面向对象3&lowbar;多态

    5.面向对象_多态 多态定义:某一种事物存在的多种形态. 例:动物中猫,狗. 猫这个对象对应的类型是猫类型. 猫 x = new 猫(); 同时猫也是动物的一种,也可以把猫称为动物. 动物 y = n ...

  7. ssh 依赖关系

    安装ssh时: sudo apt-get install openssh-server 出现错误: 下列软件包有未满足的依赖关系: openssh-server : 依赖: openssh-clien ...

  8. yii2 advance安装

    转载自:http://www.genshuixue.com/i-cxy/p/7986531 1. 前提条件,php版本得> 5.4D:\phpStudy>php -v PHP 5.5.17 ...

  9. 线性代数-矩阵-【3】矩阵加减 C和C&plus;&plus;实现

    点击这里可以跳转至 [1]矩阵汇总:http://www.cnblogs.com/HongYi-Liang/p/7287369.html [2]矩阵生成:http://www.cnblogs.com/ ...

  10. forwardPort&period;go

    packagemain import(     "encoding/json"     "flag"     "fmt"     &quot ...