知识点
相关文章
更多最近更新
更多nutch + solr —— 搭建初探
2019-03-27 01:18|来源: 网路
一. 环境:
apache-nutch-1.8
solr-4.7.0
二. nutch配置提示:
1. 配置 nutch-site.xml
<property> <name>http.agent.name</name> <value>MySpider</value> </property> <property> <name>http.robots.agents</name> <value>MySpider,*</value> </property>http.agent.name 必填
http.robots.agents 选填,若不填,fetch开始时会提示,但不影响运行
2. 修改bin/nutch 权限
chmod +x bin/nutch
3. deploy 目录只有以部署二进制包的形式安装nutch,才会出现
4. regex-urlfilter.txt 分析
# skip file: ftp: and mailto: urls -^(file|ftp|mailto):- 表示过滤掉满足后面正则表达式的urls
^表示开头
file|ftp|mailto 表示要过滤掉开头是file,ftp,mailto的urls
三. solr配置提示:
-
cp ${NUTCH_RUNTIME_HOME}/conf/schema.xml ${APACHE_SOLR_HOME}/example/solr/conf/
- vim ${APACHE_SOLR_HOME}/example/solr/conf/schema.xml
-
Copy exactly in 351 line: <field name="_version_" type="long" indexed="true" stored="true"/> (collection1/conf 中已有此项)
-
restart Solr with the command “java -jar start.jar” under ${APACHE_SOLR_HOME}/example
master上配置好nutch及solr后,移植到其他slave上。
1. scp 两个文件夹过去
2. scp /etc/profile
3. source /etc/profile
4. 注意,若hadoop已经移植过去,那么若之后master上配置有改,记得同步到其他slave上。
5. 注意权限问题。具体要给那些加上权限...不太记得了。可能用到的都附上权限吧。。
四. 排错:
1. 运行nutch提示后退出:Generator: 0 records selected for fetching, exiting ...
bin/nutch readdb data/crawldb -stats
可以查看CrawlDB的信息
hadoop@master:~/apache-nutch-1.8$ bin/nutch readdb data/crawldb -stats CrawlDb statistics start: data/crawldb Statistics for CrawlDb: data/crawldb TOTAL urls: 1 retry 1: 1 min score: 1.0 avg score: 1.0 max score: 1.0 status 1 (db_unfetched): 1 CrawlDb statistics: done
db_unfetched 为1,但是retry也为1,所以是抓取失败了。
2. Job failed
command
bin/crawl urls/seed.txt data http://localhost:8983/solr/ 2
error
Indexer: java.io.IOException: Job failed! at org.apache.hadoop.mapred.JobClient.runJob(JobClient.java:1357) at org.apache.nutch.indexer.IndexingJob.index(IndexingJob.java:114) at org.apache.nutch.indexer.IndexingJob.run(IndexingJob.java:176) at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65) at org.apache.nutch.indexer.IndexingJob.main(IndexingJob.java:186)
solr log
org.apache.solr.common.SolrException: ERROR: [doc=http://www.163.com/] unknown field 'host'
nutch log
org.apache.solr.common.SolrException: Bad Request Bad Request request: http://localhost:8080/solr/update?wt=javabin&version=2
解决
修改 ${APACHE_SOLR_HOME}/example/solr/collection1/conf/schema.xml
在<fields> 与 <fields> 中间增加
<field name="host" type="string" stored="false" indexed="true"/> <field name="digest" type="string" stored="true" indexed="false"/> <field name="segment" type="string" stored="true" indexed="false"/> <field name="boost" type="float" stored="true" indexed="false"/> <field name="tstamp" type="date" stored="true" indexed="false"/>
效果
检索抓取到的内容,用浏览器打开 http://localhost:8983/solr/#/collection1/query
http://stackoverflow.com/questions/13429481/error-while-indexing-in-solr-data-crawled-by-nutch
http://blog.csdn.net/panjunbiao/article/details/12171147
3. Warning: $HADOOP_HOME is deprecated.
在/etc/profile中加
export HADOOP_HOME_WARN_SUPPRESS=1
4. nutch在hadoop上跑时出错:
14/04/08 12:28:07 INFO mapred.JobClient: Map output records=1 14/04/08 12:28:07 INFO crawl.Generator: Generator: finished at 2014-04-08 12:28:07, elapsed: 00:00:51 ls: 无法访问data/segments/: 没有那个文件或目录 Operating on segment : Fetching :
解决:见我另一篇博文:
nutch on hadoop 遇到 ls: 无法访问data/segments: 没有那个文件或目录
五. 待解决:
1. 压力测试
http://blog.csdn.net/shirdrn/article/details/7055355
2. anchor
org.apache.solr.common.SolrException: ERROR: [doc=http://baike.baidu.com/] unknown field 'anchor'
怀疑是中文分词之类的问题
http://www.163.com/ 没问题
http://www.baidu.com http://www.renren.com 有问题
http://nutch.apache.org/ http://hadoop.apache.org/ http://lucene.apache.org/ 没问题
3. Generator:0 records selected for fetching,
怀疑是url数量不够,增加url之后,问题解决。
六. 附录:
观察nutchcrawl的每一步
Solr配置文件:schema.xml
深入Solr实战
Lucene/ Solr开发经验
NutchTutorial
Hadoop Shell命令
DataNode节点上数据块的完整性——DataBlockScannerhadoop nutch solr 环境搭建手册
Solr调研总结
Nutch的命令详解
Nutch 插件系统浅析
转自:http://blog.csdn.net/kradnangel/article/details/22804281
相关问答
更多-
为什么使用nutch和solr[2023-07-13]
恩,这个我没有集成过,但是我想在不操作数据库的基础上,是不需要修改application.xml和struts.xml这些配置文件的,只需要把爬行的xml文件配置到web.xml里面就可以了,定时爬取的话就在application.xml里面配置quartz任务。 希望能够帮到你 -
Nutch与Solr(Nutch versus Solr)[2022-06-20]
Nutch是构建网络爬虫和搜索引擎的框架。 Nutch可以完成从收集网页到建立倒排索引的整个过程。 它也可以将这些索引推送到Solr。 Solr主要是一个搜索引擎,支持分面搜索和许多其他简洁的功能。 但Solr不提取数据,你必须提供它。 因此,也许你必须要问的第一件事是在你是否有可用的索引数据(在XML中,在CMS或数据库中)。 在这种情况下,您应该只使用Solr并为其提供数据。 另一方面,如果你不得不从网络上获取数据,你可能更愿意使用Nutch。 Nutch is a framework to build ... -
我快速浏览了GH存储库,因为代码实际上像普通的ParseFilter您应该能够使用parsechecker命令检查数据是否被正确拉出: $ bin/nutch parsechecker
这应输出由Nutch(contentType,signature,url)和ParseData (状态,标题,外ParseData等)提取的常用数据以及从插件中提取的任何其他信息。 您还可以使用indexchecker命令: $ bin/nutch indexchecker 这将输出将由活动索引插 ... -
感谢Lewis John Mcgibbney,我意识到应该使用索引工具,如下所示: bin / nutch索引-D solr.server.url =“https://gateway.watsonplatform.net/retrieve-and-rank/api/v1/solr_clusters/CLUSTER-ID/solr/admin/collections -D solr.auth = true -D solr.auth.username =“USERNAME”-D solr.auth.passwo ...
-
您需要将以下Apache Commons库添加到类路径中: commons-httpclient.jar (您可以将它放在nutch安装所使用的其他JAR所在的文件夹中)。 你可以在这里找到当前版本的HttpClient http://hc.apache.org/httpcomponents-client-ga/ 请注意,您的Nutch版本可能使用较旧版本的HttpClient,而当前版本的HttpClient与旧版本不兼容。 在这种情况下,您需要下载旧版本的HttpClient,并在您的库中包含旧版本。 ...
-
在signatureField标签中,我有“id”而不是“signature”
true true ... -
nutch模式将id(= url)定义为teh唯一键。 如果你重新抓取url,当nutch将数据发布到solr时,文档将被替换为solr索引。 The nutch schema defines id (= url) as teh unique key. If you re-crawl the url teh document will be replaced in solr index when nutch posts the data to solr.
-
使用cygwin,这是一个很好的指南,可以将它们组合在一起: http://amac4.blogspot.com/2013/07/setting-up-solr-with-apache-tomcat-be.html Use cygwin, heres an excellent guide to set them up together: http://amac4.blogspot.com/2013/07/setting-up-solr-with-apache-tomcat-be.html
-
您只需要配置Nutch( http.agent.name )所需的参数,并指出您想要在所需的Solr实例中索引您的内容,例如使用您只需要添加solr.server.url的bin/crawl脚本solr.server.url属性: $ bin/crawl -i -D solr.server.url=http://localhost:8983/solr/ urls/ crawl/ 2 如果您在终端中执行bin/crawl ,您将获得有关可用选项的更多信息。 这里有更全面的介绍。 对于2.x分支, bin/c ...
-
在目前阶段,Nutch只负责抓取网页,这意味着访问网页,提取内容,找到更多链接并重复这个过程(我正在跳过很多复杂的东西,但希望你能得到这个想法) 。 爬网过程的最后一步是将数据存储在后端(ES / Solr是1.x分支上支持的数据存储)。 因此,在这个步骤中,Solr开始发挥作用,在Nutch完成其工作之后,您需要将数据存储在某处以便能够在其上执行查询:这是Solr作业。 前段时间Nutch包含了编写倒排索引的能力(正如问题中所解释的那样),但是决定(也是前一段时间)是弃用这个以支持使用Solr / ES( ...