`
javasss
  • 浏览: 66552 次
  • 性别: Icon_minigender_1
  • 来自: 河南
社区版块
存档分类
最新评论

Nutch 文件配置

 
阅读更多
Nutch 的配置文件几乎覆盖了Nutch 所有的功能。以前在网上看到过一个关于Nutch-default.XML  配置项解释,地址我没收藏,和本文配合起来看,会更好一些。这里我也不打算对其配置文件中的每一项做解释,如果在下面的解释里找不到想要的内容,请发表评论,我会回复的。

<property>
  <name>http.max.delays</name>
  <value>20</value>
  <description>The number of times a thread will delay when trying to
  fetch a page.  Each time it finds that a host is busy, it will wait
  fetcher.server.delay.  After http.max.delays attepts, it will give
  up on the page for now.</description>
</property>

爬虫的网络延时线程等待时间,以秒计时 , 默认的配时间是3秒,视网络状况而定。如果在爬虫运行的时候发现服务器返回了主机忙消息,则等待时间由fetcher.server.delay 决定,所以在网络状况不太好的情况下fetcher.server.delay 也设置稍大一点的值较好,此外还有一个http.timeout 也和网络状况有关系。

<property>
  <name>http.content.limit</name>
  <value>65536</value>
  <description>The length limit for downloaded content, in bytes.
  If this value is nonnegative (>=0), content longer than it will be truncated;
  otherwise, no truncation at all.
  </description>
</property>

描述爬虫抓取的文档内容长度的配置项。原来的值是 65536 , 也就是说抓取到的一个文档截取 65KB左右,超过部分将被忽略,对于抓取特定内容的搜索引擎需要修改此项,比如XML文档。

<property>
  <name>db.default.fetch.interval</name>
  <value>30</value>
  <description>The default number of days between re-fetches of a page.
  </description>
</property>

这个功能对定期自动爬取需求的开发有用,设置多少天重新爬一个页面。

<property>
  <name>fetcher.server.delay</name>
  <value>5.0</value>
  <description>The number of seconds the fetcher will delay between
   successive requests to the same server.</description>
</property>

<property>
  <name>fetcher.threads.fetch</name>
  <value>10</value>
  <description>The number of FetcherThreads the fetcher should use.
    This is also determines the maximum number of requests that are
    made at once (each FetcherThread handles one connection).</description>
</property>

<property>
  <name>fetcher.threads.per.host</name>
  <value>1</value>
  <description>This number is the maximum number of threads that
    should be allowed to access a host at one time.</description>
</property>

<property>
  <name>fetcher.verbose</name>
  <value>false</value>
  <description>If true, fetcher will log more verbosely.</description>
</property>



这几个是爬虫线程的配置项,看名称就容易理解。

<property>
  <name>parser.threads.parse</name>
  <value>10</value>
  <description>Number of ParserThreads ParseSegment should use.</description>
</property>

解析爬取到的文档线程数, 和爬虫线程对应,因为爬虫主要的处理类是有很多地方使用到了同步,所以此配置项和爬虫线程保持一直对处理有好处。

<property>
  <name>fs.default.name</name>
  <value>local</value>
  <description>The name of the default file system.  Either the
  literal string "local" or a host:port for NDFS.</description>
</property>


分布式文件系统 使用的配置项,默认的是  local 表示 使用本地文件系统,如果使用 host:port 的形式表示使用分布式文件系统NDFS,此处的文件系统地址是 nameserver ,也就是通过 bin/nutch namenode xxxx启动的 主机地址和端口号。

<property>
  <name>ndfs.name.dir</name>
  <value>/tmp/nutch/ndfs/name</value>
  <description>Determines where on the local filesystem the NDFS name node
      should store the name table.</description>
</property>

分布式文件系统namenode 使用的 的存放数据的目录 ,Namenode 会使用此项,另外在启动 namenode 或datanode的时候也可以加上 路径作为参数也可以生效。

<property>
  <name>ndfs.data.dir</name>
  <value>/tmp/nutch/ndfs/data</value>
  <description>Determines where on the local filesystem an NDFS data node
      should store its blocks.</description>
</property>

分布式文件系统ndatanode 使用的 的存放数据的目录 ,datanode 会使用此项,另外在启动 datanode的时候也可以加上 路径作为参数也可以生效。

<property>
  <name>indexer.max.tokens</name>
  <value>10000</value>
  <description>
  The maximum number of tokens that will be indexed for a single field
  in a document. This limits the amount of memory required for
  indexing, so that collections with very large files will not crash
  the indexing process by running out of memory.

  Note that this effectively truncates large documents, excluding
  from the index tokens that occur further in the document. If you
  know your source documents are large, be sure to set this value
  high enough to accomodate the expected size. If you set it to
  Integer.MAX_VALUE, then the only limit is your memory, but you
  should anticipate an OutOfMemoryError.
  </description>
</property>

这个配置项的功能是限制索引的时候每个文档的单个字段最大10000个Tokens,也就是说在采用默认的一元分词的 情况下,最大的文档字数限制是10000,如果采用其他中文非一元分词系统,则索引的单个文档单个字段将会超过10000个,对内存有影响。

<property>
  <name>indexer.mergeFactor</name>
  <value>200</value>
  <description>The factor that determines the frequency of Lucene segment
  merges. This must not be less than 2, higher values increase indexing
  speed but lead to increased RAM usage, and increase the number of
  open file handles (which may lead to "Too many open files" errors).
  NOTE: the "segments" here have nothing to do with Nutch segments, they
  are a low-level data unit used by Lucene.
  </description>
</property>

合并因子,在建立索引的时候用到,表示索引200个文档的时候回写到存储设备。

<property>
  <name>indexer.minMergeDocs</name>
  <value>50</value>
  <description>This number determines the minimum number of Lucene
  Documents buffered in memory between Lucene segment merges. Larger
  values increase indexing speed and increase RAM usage.
  </description>
</property>


这个配置项对内存影响巨大,功能是在建立索引的时候最小的合并文档数量,这个值设置太小一个会影响索引速度,另外一个在需要索引的文档数量很大的时候会出现 Too Many Open files 的错误,这个时候需要调整此配置项,有试验表明1000的时候会有比较快的索引速度,但我把此项值调整到10000 , 索引的时候最高内存占用到1.8G,索引创建速度是25page/sec , 并且多次索引的时候有一个衰减。不过对查询的相应时间有很大提升,如果内存足够的话修改较大的值比较好。

<property>
  <name>indexer.maxMergeDocs</name>
  <value>50</value>
  <description>This number determines the maximum number of Lucene
  Documents to be merged into a new Lucene segment. Larger values
  increase indexing speed and reduce the number of Lucene segments,
  which reduces the number of open file handles; however, this also
  increases RAM usage during indexing.
  </description>
</property>

这个好像不需要设置,因为默认的值是 Integer.MAX_VALUE , 不会比这个更大了。

<property>
  <name>searcher.summary.context</name>
  <value>5</value>
  <description>
  The number of context terms to display preceding and following
  matching terms in a hit summary.
  </description>
</property>

这个比较有用,在前面的文章里有介绍。

<property>
  <name>searcher.summary.length</name>
  <value>20</value>
  <description>
  The total number of terms to display in a hit summary.
  </description>
</property>

在前面的文章里也有介绍。




<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>

<property>
  <name>plugin.includes</name>
  <value>protocol-httpclient|urlfilter-regex|parse-(text|html|rss)|index-more|query-(basic|site|url)</value>
  <description>Regular expression naming plugin directory names to
  include.  Any plugin not matching this expression is excluded.  By
  default Nutch includes crawling just HTML and plain text via HTTP,
  and basic indexing and search plugins.
  </description>
</property>

这两个是配置 插件功能 的配置项 ,plugin.folders制定插件加载路径,plugin.includes表示需要加载的插件列表,关于插件后面会专门做介绍。



<property>
  <name>parser.character.encoding.default</name>
  <value>windows-1252</value>
  <description>The character encoding to fall back to when no other information
  is available</description>
</property>

解析文档的时候使用的默认编码windows-1252 好像比较少用到的一种编码,我不太熟悉。

<property>
  <name>parser.html.impl</name>
  <value>neko</value>
  <description>HTML Parser implementation. Currently the following keywords
  are recognized: "neko" uses NekoHTML, "tagsoup" uses TagSoup.
  </description>
</property>

制定解析HTML文档的时候使用的解析器, NEKO功能比较强大,后面会有专门的文章介绍Neko 从HTML到 TEXT以及html片断的解析等功能做介绍。


<property>
  <name>extension.clustering.hits-to-cluster</name>
  <value>100</value>
  <description>Number of snippets retrieved for the clustering extension
  if clustering extension is available and user requested results
  to be clustered.</description>
</property>

聚合功能,对搜索结果有聚合需求的应用可能会用到。

<property>
  <name>extension.ontology.extension-name</name>
  <value></value>
  <description>Use the specified online ontology extension. If empty,
  the first available extension will be used. The "name" here refers to an 'id'
  attribute of the 'implementation' element in the plugin descriptor XML
  file.</description>
</property>


人工智能,这个功能在我以后的开发过程中会逐步深入,等我有相关的经验以后在给大家介绍。◎_◎

<property>
  <name>query.url.boost</name>
  <value>4.0</value>
  <description> Used as a boost for url field in Lucene query.
  </description>
</property>

<property>
  <name>query.anchor.boost</name>
  <value>2.0</value>
  <description> Used as a boost for anchor field in Lucene query.
  </description>
</property>


<property>
  <name>query.title.boost</name>
  <value>1.5</value>
  <description> Used as a boost for title field in Lucene query.
  </description>
</property>

<property>
  <name>query.host.boost</name>
  <value>2.0</value>
  <description> Used as a boost for host field in Lucene query.
  </description>
</property>

<property>
  <name>query.phrase.boost</name>
  <value>1.0</value>
  <description> Used as a boost for phrase in Lucene query.
  Multiplied by boost for field phrase is matched in.
  </description>
</property>

以上的几个关于搜索结果排序的分值计算因子在以后的搜索结果排序会专门做介绍,这几个项对垂直搜索的用处不太大。

<property>
  <name>lang.analyze.max.length</name>
  <value>2048</value>
  <description> The maximum bytes of data to uses to indentify
  the language (0 means full content analysis).
  The larger is this value, the better is the analysis, but the
  slowest it is.
  </description>
</property>

和语言有关系,分词的时候会用到,不过我没用过这个配置项。

还有几个重要的配置项在 nutch-site.xml里面配置。

<property>   
  <name>searcher.dir</name>   
  <value>C:\</value>
</property>
可以有两种方式 ,如果指向的目录下面有 search-servers.txt 文件 ,那么优先处理 search-servers.txt文件中的内容 ,并解析其中复合
hostname port
格式的内容(即分布式查询请求),解析到后就想该服务器发送查询请求,如果没有则查找 segements 目录 ,segments 是本地索引文件。
如果两个都没有找到,她就要报错了。
search-servers.txt
内容很简单  例如:
127.0.0.1 9999
不过需要注意的是 ,这个 9999的端口 启动的 是查询服务器  ,是用 bin/nutch server 9999 的命令启动的,
和 namenode 启动比较相似 ,我当初接触的时候就以为是 namenode 的地址,郁闷的很久。
namenode  和 searchserver 结合不太好 , 没有提供直接从 namenode 到searchserver 的 文件访问接口,需要自己开发,如果大
家知道有可以直接从 namenode 到searchserver 的方法或者现成的程序,请告诉我一下,我需要,要是实在找不到,那就没办法了,自己写。
我现在从namenode 到 searchserver的方法比较原始,不值得推荐,所以就不作介绍了。



分享到:
评论

相关推荐

    eclipse配置nutch,eclipse配置nutch

    为了使Nutch在Eclipse中正常运行,你需要修改Nutch的默认配置文件`nutch-default.xml`。具体而言,将`plugin.folders`参数改为`"./src/plugin"`,以确保Nutch能够识别到项目的插件目录。 #### 步骤5:设置URL文件 ...

    Nutch_的配置文件

    在Nutch的运行过程中,配置文件起着至关重要的作用,它们定义了Nutch的行为方式和各种参数设置。Nutch的配置文件主要分为三类: 1. **Hadoop的配置文件**:包括`Hadoop-default.xml`和`Hadoop-site.xml`。`Hadoop-...

    Linux下Nutch单机配置

    ### Linux下Nutch单机配置知识点详解 #### 一、环境搭建与配置 **1.1 环境介绍** 本文档将详细介绍如何在Linux环境下进行Nutch的单机配置。所使用的具体环境如下: - **操作系统**: Red Hat Linux 9 - **Nutch...

    nutch10配置(解决代理问题)

    2. **General Configuration**:通用配置文件`conf/nutch-default.xml`,这里包含了关于代理服务器的配置信息。 - `&lt;property&gt;`标签中的配置项用于指定代理服务器的主机名、端口、用户名和密码等信息。 - `&lt;name&gt;...

    Nutch安装配置

    6. **配置Nutch**:修改`conf/nutch-site.xml`文件以设置抓取策略、存储位置、抓取间隔等参数。例如,设置`fetcher.threads.per.queue`来控制并发抓取的线程数,以及`db.default.url.meta`来定义元数据字段。 7. **...

    搜索引擎nutch配置

    打开`conf/nutch-site.xml`文件,这是Nutch的主要配置文件。以下是一些关键配置项: - `generalcrawl.interval`: 定义抓取间隔,单位为秒。 - `db.default.urlnormalizers`: 指定URL规范化规则。 - `db.default....

    nutch_1.4在windows下安装配置.pdf

    - 在 `conf/nutch-site.xml` 文件中添加如下配置: ```xml &lt;name&gt;http.agent.name&lt;/name&gt; &lt;value&gt;MyNutchSpider ``` 2. **准备爬行种子文件** - 在 `local` 目录下创建 `urls` 文件夹,并在其中创建 `seed...

    nutch_1.4配置

    ### Apache Nutch 1.4在Windows下的安装与配置详解 #### 一、Apache Nutch简介及重要性 Apache Nutch是一款用Java语言编写的开源网络爬虫项目,旨在自动化地抓取网页中的链接,检查并修复坏链接,以及创建已访问...

    Linux下Nutch分布式配置和使用.rar

    1 /etc/hosts文件配置 ............................................... 2 2 SSH无密码验证配置 ................................................ 2 2.1配置所有节点之间SSH无密码验证 ..........................

    Windows下配置nutch

    - 配置 Nutch 相关的配置文件,如上述方法。 5. **配置注意事项**: - 在 `nutch-site.xml` 中,`http.agent.name` 属性用于定义爬虫的用户代理名称,通常需要更改,避免被服务器识别为恶意爬虫。 - `crawl-...

    Nutch配置环境\Nutch1[1].4_windows下eclipse配置图文详解.docx

    本文将详细介绍如何在Windows环境下配置Nutch 1.4,并使用Eclipse进行开发。以下是你需要知道的关键步骤: 1. **安装JDK**: 在配置Nutch之前,首先确保已安装Java Development Kit (JDK)。这里推荐使用JDK 1.6。...

    Nutch 配置

    4. **Nutch源码编译**:进入Nutch源码目录,运行 `ant` 命令,这将会生成一个`runtime`目录,其中包含运行Nutch所需的配置和可执行文件。 5. **复制Hadoop配置文件**:将Hadoop的配置文件如`core-site.xml`, `...

    nutch配置与安装

    ### Nutch配置与安装知识点详解 #### 一、Nutch简介 Nutch是一款开源的Web爬虫项目,基于Apache Hadoop构建,能够抓取、处理和索引互联网上的信息。Nutch提供了高度可定制化的配置选项,使得用户可以根据自己的需求...

    nutch安装开发环境的配置

    在安装和配置 Nutch 开发环境时,可能会遇到各种问题,以下是对这些问题的详细解答。 首先,确保你已经下载了 Nutch 的正确版本。Nutch 的官方网站可能只提供最新的稳定版本,如 1.6 或 2.1。如果需要其他版本,...

    Nutch 安装与配置文档

    在实际使用中,根据具体需求可能还需要对Nutch的其他配置文件进行调整,如`conf/nutch-default.xml`和`conf/nutch-site.xml`,以便优化抓取策略和索引设置。同时,了解Nutch的抓取流程和原理,对于进行更高级的网络...

    nutch 详细分析(包括配置文件等)

    Nutch 的配置主要通过修改`nutch-default.xml`完成,这个文件包含了Nutch的各种默认设置。用户可以通过创建`site.xml`并覆盖默认值来自定义配置。配置项包括抓取策略、解析器设置、索引参数等,比如抓取间隔、重试...

    windows下的nutch配置总结

    - 提供的`.chm`和`.doc`文件很可能是Nutch配置的详细指南或教程,这些文档可以帮助理解配置过程中的细节,解决遇到的问题。 10. **扩展和优化**: - Nutch允许自定义插件来扩展其功能,例如解析特定格式的文件,...

    mp3文件信息解析-nutch使用

    5. **配置调整**:在Nutch的配置文件中,设置相应的解析优先级和处理策略。 压缩包子文件的文件名称列表中提到了"org",这可能是指Nutch相关的源代码包或类库。在实际操作中,开发者可能需要查看Nutch的源代码,...

Global site tag (gtag.js) - Google Analytics