Nutch 的配置文件

来源:百度文库 编辑:神马文学网 时间:2024/04/28 03:55:57
 Nutch 的配置文件
Nutch 的配置文件几乎覆盖了Nutch 所有的功能。以前在网上看到过一个关于Nutch-default.XML  配置项解释,地址我没收藏,和本文配合起来看,会更好一些。这里我也不打算对其配置文件中的每一项做解释,如果在下面的解释里找不到想要的内容,请发表评论,我会回复的。

http.max.delays
20
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.


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

http.content.limit
65536
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.


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

db.default.fetch.interval
30
The default number of days between re-fetches of a page.


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

fetcher.server.delay
5.0
The number of seconds the fetcher will delay between
successive requests to the same server.



fetcher.threads.fetch
10
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).



fetcher.threads.per.host
1
This number is the maximum number of threads that
should be allowed to access a host at one time.



fetcher.verbose
false
If true, fetcher will log more verbosely.

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

parser.threads.parse
10
Number of ParserThreads ParseSegment should use.

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

fs.default.name
local
The name of the default file system.  Either the
literal string "local" or a host:port for NDFS.


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

ndfs.name.dir
/tmp/nutch/ndfs/name
Determines where on the local filesystem the NDFS name node
should store the name table.


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

ndfs.data.dir
/tmp/nutch/ndfs/data
Determines where on the local filesystem an NDFS data node
should store its blocks.


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

indexer.max.tokens
10000

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.


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

indexer.mergeFactor
200
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.


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

indexer.minMergeDocs
50
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.


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

indexer.maxMergeDocs
50
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.


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

searcher.summary.context
5

The number of context terms to display preceding and following
matching terms in a hit summary.


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

searcher.summary.length
20

The total number of terms to display in a hit summary.


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

plugin.folders
plugins
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.



plugin.includes
protocol-httpclient|urlfilter-regex|parse-(text|html|rss)|index-more|query-(basic|site|url)
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.


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

parser.character.encoding.default
windows-1252
The character encoding to fall back to when no other information
is available


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

parser.html.impl
neko
HTML Parser implementation. Currently the following keywords
are recognized: "neko" uses NekoHTML, "tagsoup" uses TagSoup.


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

extension.clustering.hits-to-cluster
100
Number of snippets retrieved for the clustering extension
if clustering extension is available and user requested results
to be clustered.


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

extension.ontology.extension-name

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.


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

query.url.boost
4.0
Used as a boost for url field in Lucene query.



query.anchor.boost
2.0
Used as a boost for anchor field in Lucene query.



query.title.boost
1.5
Used as a boost for title field in Lucene query.



query.host.boost
2.0
Used as a boost for host field in Lucene query.



query.phrase.boost
1.0
Used as a boost for phrase in Lucene query.
Multiplied by boost for field phrase is matched in.


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

lang.analyze.max.length
2048
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.


和语言有关系,分词的时候会用到,不过我没用过这个配置项。
还有几个重要的配置项在 nutch-site.xml里面配置。

searcher.dir
C:\

可以有两种方式 ,如果指向的目录下面有 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的方法比较原始,不值得推荐,所以就不作介绍了。