Rumah > Artikel > pangkalan data > Nutch1.8+Hadoop1.2+Solr4.3分布式集群配置
Nutch 是一个开源Java 实现的搜索引擎。它提供了我们运行自己的搜索引擎所需的全部工具。包括全文搜索和Web爬虫。当然在百度百科上这种方法在Nutch1.2之后,已经不再适合这样描述Nutch了,因为在1.2版本之后,Nutch专注的只是爬取数据,而全文检索的部分彻底
Nutch 是一个开源Java 实现的搜索引擎。它提供了我们运行自己的搜索引擎所需的全部工具。包括全文搜索和Web爬虫。当然在百度百科上这种方法在Nutch1.2之后,已经不再适合这样描述Nutch了,因为在1.2版本之后,Nutch专注的只是爬取数据,而全文检索的部分彻底的交给Lucene和Solr,ES来做了,当然因为他们都是近亲关系,所以Nutch抓取完后的数据,非常easy的就能生成全文索引。序号 | 名称 | 职责描述 |
1 | Nutch1.8 | 主要负责爬取数据,支持分布式 |
2 | Hadoop1.2.0 | 使用MapReduce进行并行爬取,使用HDFS存储数据,Nutch的任务提交在Hadoop集群上,支持分布式 |
3 | Solr4.3.1 | 主要负责检索,对爬完后的数据进行搜索,查询,海量数据支持分布式 |
4 | IK4.3 | 主要负责,对网页内容与标题进行分词,便于全文检索 |
5 | Centos6.5 | Linux系统,在上面运行nutch,hadoop等应用 |
6 | Tomcat7.0 | 应用服务器,给Solr提供容器运行 |
7 | JDK1.7 | 提供JAVA运行环境 |
8 | Ant1.9 | 提供Nutch等源码编译 |
9 | 屌丝软件工程师一名 | 主角 |
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <!-- Put site-specific property overrides in this file. --> <configuration> <property> <name>http.agent.name</name> <value>mynutch</value> </property> <property> <name>http.robots.agents</name> <value>mynutch,*</value> <description>The agent strings we'll look for in robots.txt files, comma-separated, in decreasing order of precedence. You should put the value of http.agent.name as the first agent name, and keep the default * at the end of the list. E.g.: BlurflDev,Blurfl,* </description> </property> <property> <name>plugin.folders</name> <!-- local模式下使用下面的配置 --> <value>./src/plugin</value> <!-- 集群模式下,使用下面的配置 --> <value>plugins</value> <!-- <value>D:\nutch编译好的1.8\Nutch1.8\src\plugin</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> </configuration>
export HADOOP_HOME=/root/hadoop1.2 export PATH=$HADOOP_HOME/bin:$PATH ANT_HOME=/root/apache-ant-1.9.2 export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL export JAVA_HOME=/root/jdk1.7 export PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
[root@master bin]# which hadoop /root/hadoop1.2/bin/hadoop [root@master bin]#
<?xml version="1.0" encoding="UTF-8" ?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- Description: This document contains Solr 3.1 schema definition to be used with Solr integration currently build into Nutch. See https://issues.apache.org/jira/browse/NUTCH-442 https://issues.apache.org/jira/browse/NUTCH-699 https://issues.apache.org/jira/browse/NUTCH-994 https://issues.apache.org/jira/browse/NUTCH-997 https://issues.apache.org/jira/browse/NUTCH-1058 https://issues.apache.org/jira/browse/NUTCH-1232 and http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/ example/solr/conf/schema.xml?view=markup for more info. --> <schema name="nutch" version="1.5"> <types> <fieldtype name="string" class="solr.StrField" sortmissinglast="true" omitnorms="true"></fieldtype> <fieldtype name="long" class="solr.TrieLongField" precisionstep="0" omitnorms="true" positionincrementgap="0"></fieldtype> <fieldtype name="float" class="solr.TrieFloatField" precisionstep="0" omitnorms="true" positionincrementgap="0"></fieldtype> <fieldtype name="date" class="solr.TrieDateField" precisionstep="0" omitnorms="true" positionincrementgap="0"></fieldtype> <!-- 配置IK分词 --> <fieldtype name="ik" class="solr.TextField" positionincrementgap="100"> <analyzer type="index"> <tokenizer class="org.wltea.analyzer.lucene.IKTokenizerFactory" usesmart="false"></tokenizer> <!-- in this example, we will only use synonyms at query time <filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/> --> <!-- <filter class="solr.LowerCaseFilterFactory"/> --> </analyzer> <analyzer type="query"> <tokenizer class="org.wltea.analyzer.lucene.IKTokenizerFactory" usesmart="false"></tokenizer> <!--<filter class="org.wltea.analyzer.lucene.IKSynonymFilterFactory" autoupdate="false" synonyms="synonyms.txt" flushtime="20" /> --> <!--<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/> --> <!--<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/> --> <!-- <filter class="solr.LowerCaseFilterFactory"/> --> </analyzer> </fieldtype> <fieldtype name="text" class="solr.TextField" positionincrementgap="100"> <analyzer type="index"> <tokenizer class="solr.StandardTokenizerFactory"></tokenizer> <filter class="solr.StopFilterFactory" ignorecase="true" words="stopwords.txt" enablepositionincrements="true"></filter> <!-- in this example, we will only use synonyms at query time <filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/> --> <filter class="solr.LowerCaseFilterFactory"></filter> </analyzer> <analyzer type="query"> <tokenizer class="solr.StandardTokenizerFactory"></tokenizer> <filter class="solr.StopFilterFactory" ignorecase="true" words="stopwords.txt" enablepositionincrements="true"></filter> <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignorecase="true" expand="true"></filter> <filter class="solr.LowerCaseFilterFactory"></filter> </analyzer> </fieldtype> <fieldtype name="url" class="solr.TextField" positionincrementgap="100"> <analyzer> <tokenizer class="solr.StandardTokenizerFactory"></tokenizer> <filter class="solr.LowerCaseFilterFactory"></filter> <filter class="solr.WordDelimiterFilterFactory" generatewordparts="1" generatenumberparts="1"></filter> </analyzer> </fieldtype> </types> <fields> <field name="_version_" type="long" indexed="true" stored="true"></field> <field name="id" type="string" stored="true" indexed="true"></field> <!-- core fields --> <field name="segment" type="string" stored="true" indexed="false"></field> <field name="text" type="string" stored="true" indexed="false"></field> <field name="digest" type="string" stored="true" indexed="false"></field> <field name="boost" type="float" stored="true" indexed="false"></field> <!-- fields for index-basic plugin --> <field name="host" type="string" stored="false" indexed="true"></field> <field name="url" type="url" stored="true" indexed="true" required="true"></field> <field name="content" type="ik" stored="true" indexed="true"></field> <field name="title" type="ik" stored="true" indexed="true"></field> <field name="cache" type="string" stored="true" indexed="false"></field> <field name="tstamp" type="date" stored="true" indexed="false"></field> <!-- fields for index-anchor plugin --> <field name="anchor" type="string" stored="true" indexed="true" multivalued="true"></field> <!-- fields for index-more plugin --> <field name="type" type="string" stored="true" indexed="true" multivalued="true"></field> <field name="contentLength" type="long" stored="true" indexed="false"></field> <field name="lastModified" type="date" stored="true" indexed="false"></field> <field name="date" type="date" stored="true" indexed="true"></field> <!-- fields for languageidentifier plugin --> <field name="lang" type="string" stored="true" indexed="true"></field> <!-- fields for subcollection plugin --> <field name="subcollection" type="string" stored="true" indexed="true" multivalued="true"></field> <!-- fields for feed plugin (tag is also used by microformats-reltag)--> <field name="author" type="string" stored="true" indexed="true"></field> <field name="tag" type="string" stored="true" indexed="true" multivalued="true"></field> <field name="feed" type="string" stored="true" indexed="true"></field> <field name="publishedDate" type="date" stored="true" indexed="true"></field> <field name="updatedDate" type="date" stored="true" indexed="true"></field> <!-- fields for creativecommons plugin --> <field name="cc" type="string" stored="true" indexed="true" multivalued="true"></field> <!-- fields for tld plugin --> <field name="tld" type="string" stored="false" indexed="false"></field> </fields> <uniquekey>id</uniquekey> <defaultsearchfield>content</defaultsearchfield> <solrqueryparser defaultoperator="OR"></solrqueryparser> </schema>
java.lang.Exception: java.lang.RuntimeException: Error in configuring object at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:354) Caused by: java.lang.RuntimeException: Error in configuring object at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:93) at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:64) at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:117) at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:426) at org.apache.hadoop.mapred.MapTask.run(MapTask.java:366) at org.apache.hadoop.mapred.LocalJobRunner$Job$MapTaskRunnable.run(LocalJobRunner.java:223) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:88) ... 11 more Caused by: java.lang.RuntimeException: Error in configuring object at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:93) at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:64) at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:117) at org.apache.hadoop.mapred.MapRunner.configure(MapRunner.java:34) ... 16 more Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:88) ... 19 more Caused by: java.lang.RuntimeException: x point org.apache.nutch.net.URLNormalizer not found. at org.apache.nutch.net.URLNormalizers.<init>(URLNormalizers.java:123) at org.apache.nutch.crawl.Injector$InjectMapper.configure(Injector.java:74) ... 24 more 2013-09-05 20:40:49,329 INFO mapred.JobClient (JobClient.java:monitorAndPrintJob(1393)) - map 0% reduce 0% 2013-09-05 20:40:49,332 INFO mapred.JobClient (JobClient.java:monitorAndPrintJob(1448)) - Job complete: job_local1315110785_0001 2013-09-05 20:40:49,332 INFO mapred.JobClient (Counters.java:log(585)) - Counters: 0 2013-09-05 20:40:49,333 INFO mapred.JobClient (JobClient.java:runJob(1356)) - Job Failed: NA Exception in thread "main" java.io.IOException: Job failed! at org.apache.hadoop.mapred.JobClient.runJob(JobClient.java:1357) at org.apache.nutch.crawl.Injector.inject(Injector.java:281) at org.apache.nutch.crawl.Crawl.run(Crawl.java:132) at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65) at org.apache.nutch.crawl.Crawl.main(Crawl.java:55) ========================================================================== 解决方法:在nutch-site.xml里面加入如下配置。 <property> <name>plugin.folders</name> <value>./src/plugin</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> </init>
./crawl urls mydir http://192.168.211.36:9001/solr/ 2
http://itindex.net/detail/49582-nutch1.8-hadoop1.2-solr4.3