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 intowhich HBase persists.  The URL should be 'fully-qualified'to include the filesystem scheme.  For example, to specify theHDFS directory '/hbase' where the HDFS instance's namenode isrunning at namenode.example.org on port 9000, set this value to:hdfs://namenode.example.org:9000/hbase.  By default HBase writesinto /tmp.  Change this configuration else all data will be loston 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.2.1基础教程之2.1】集成Nutch/Hbase/Solr构建搜索引擎之一:安装及运行【单机环境】...

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

  3. 【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 ...

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

    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. pgsql数据库默认配置事务类型_PostgreSQL基础教程之:初始化配置

    PostgreSQL基础教程之:初始化配置 时间:2020-04-27 来源: PostgreSQL基础教程之:初始化配置 一.配置pg_hba.conf 先说明客户端认证配置文件pg_hba.con ...

  8. Linux入门基础教程之Linux下软件安装

    Linux入门基础教程之Linux下软件安装 一.在线安装: sudo apt-get install 即可安装 如果在安装完后无法用Tab键补全命令,可以执行: source ~/.zshrc AP ...

  9. python可以处理多大的数据_科多大数据之Python基础教程之Excel处理库openpyxl详解...

    原标题:科多大数据之Python基础教程之Excel处理库openpyxl详解 科多大数据小课堂来啦~Python基础教程之Excel处理库openpyxl详解 openpyxl是一个第三方库,可以处 ...

最新文章

  1. 培训第二弹:全国大学生智能汽车竞赛百度竞速组预告
  2. Hibernate 关联映射 之 多对多 关联(二) 之拆分
  3. pycharm没有python interpreter_首次安装Pycharm出现No Python interpreter selected解决方法
  4. raspberry pi_我如何使用Raspberry Pi与孙辈联系
  5. Linux如何自动获取IP地址
  6. 解决方案-CMake error: error in configuration process, project files may be invalid(WindowsVS可参考)
  7. 8天玩转并行开发——第六天 异步编程模型
  8. lora信号测试小助手_LoRa技术——30个常见问题解答
  9. 海德汉伺服驱动器电源维修UVR150D北京
  10. http中长连接与短连接的区别,和实现方式。
  11. bool类型转int, 或者bool数组对象转int/float数组对象
  12. word论文排版和写作02:插入算法的伪代码
  13. OR-Tools工具介绍以及实战(从入门到超神Python版)
  14. 基于ROS设计一款机械臂控制系统 [转发]
  15. 常用进制数转换(二进制、八进制、十进制、十六进制)【数电笔记】
  16. 如何在Hyper-V、Virtual PC等虚拟机中使用USB设备
  17. [超详细] Git 远程仓库及回滚日志操作
  18. 2020曼彻斯特大学计算机2020,2020年曼彻斯特大学申请要求完整版
  19. 管理系统菜单父子结构,有parentId,快速获取结构树代码
  20. Ubuntu与Windows之间设置共享文件夹

热门文章

  1. 【讲解】1030 Travel Plan (30 分)【DFS】_41行代码Ac
  2. ae saber插件_入门AE:影视特效中的黑洞是怎么做的?附带教程
  3. Kubernetes二进制部署——证书的制作和ETCD的部署
  4. Java获取并输出两日期间的所有日期 .
  5. java调用c dll,指针参数和结构体参数搞定
  6. Oracle打开虚拟机闪退,虚拟机上启动Oracle服务为什么自动停止,怎么处理?
  7. sum 去重_Excel函数,用到什么学什么!多条件求和神器之SUMIFS和去重
  8. 是什么包_包粽子教程,喜欢的收藏,以后想吃什么样的都可以自己包
  9. java信号灯_java 多线程-信号灯法
  10. 阿里docker安装mysql_docker安装mysql