nutch2.3伪分布式安装

1.安装 antjava

下载并解压ant安装包node

tar -zxvf apache-ant-1.9.4-bin.tar.gzweb

 mv apache-ant-1.9.4/  antapache

配置环境变量vim

vim .bash_profile 浏览器


#apache-ant-1.9.4tomcat

export ANT_HOME=/nutch/antbash

export ANT_BIN=/nutch/ant/bin服务器

export PATH=$PATH:$ANT_HOME/binapp


source .bash_profile 


ant -version

Apache Ant(TM) version 1.9.4 compiled on April 29 2014


下载解压怒提出安装包

tar -zxvf apache-nutch-2.2.1-src.tar.gz


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

<property>  

<name>http.agent.name</name>  

<value>Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like 


Gecko) Chrome/28.0.1500.95 Safari/537.36</value>  

</property>  



vim ivy/ivy.xml文件,找到:


<dependency org="org.apache.gora" name="gora-hbase" rev="0.5"  

conf="*->default" />  并把原有的注释去掉 修改ivy/ivy.xml文件,找到:


<dependency org="org.apache.gora" name="gora-hbase" rev="0.5"  

conf="*->default" />  并把原有的注释去掉 

<dependency org="org.apache.hadoop" name="hadoop-common"

      rev="2.5.0" conf="*->default">



vim  conf/gora.properies

gora.datastore.default=org.apache.gora.hbase.store.HBaseStore


cp /usr/local/hbase/conf/hbase-site.xml /usr/local/nutch/conf/ 


antruntime


##nutch 安装完毕!!!

#####################################################

集成solr

[root@localhost solr]# tar –zxvf solr-4.7.0.tgz


2.2 启动Jetty

这里使用Solr自带的Jetty服务器

 

[root@localhost solr]# cd solr-4.7.0/example

[root@localhost example]# java -jar start.jar

2.3 验证

在浏览器输入:http://192.168.4.150:8983/solr#/collection1/query中国人民解放军

 

3.为Solr配置IK分词

3.1 下载IK-Analyzer-2012

解压以后,将IKAnalyzer.cfg.xml、IKAnalyzer2012_FF.jar、stopword.dic三个文件上传


到/usr/solr/solr-4.7.0/example/solr-webapp/webapp/WEB-INF/lib/目录下

3.2 修改/usr/solr/solr-4.7.0/example/solr/collection1/conf/schema.xml配置文件

 

[root@localhost solr]# cd /usr/solr/solr-4.7.0/example/solr/collection1/conf/

[root@localhost solr]# vi schema.xml

在<type></types>中增长以下内容:

 

<fieldTypename="text_ik" class="solr.TextField">

 <analyzer 


type="index"isMaxWordLength="false"class="org.wltea.analyzer.lucene.IKAnalyzer"/>

 <analyzer type="query"isMaxWordLength="true" 


class="org.wltea.analyzer.lucene.IKAnalyzer"/>

</fieldType>

3.3 验证

 

重启Solr,打开http://10.192.87.198:8983/solr/#/collection1/analysis,测试一下:


4.6 集成Solr

编辑/usr/solr/solr-4.7.0/example/solr/collection1/conf/schema.xml文件,在<field>…


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

   <field name="anchor"type="string" stored="true" indexed="true" multiValued="true"/>

   <fieldname="cache" type="string" stored="true"indexed="false"/>

重启Solr,从新爬取

1

[root@localhost apache-nutch-1.7]# bin/nutch crawl urls -dir crawl -depth 2 -topN 5 -


solr http://10.192.86.156:8983/solr

4.7 查看结果

在浏览器输入http://10.192.86.156:8983/solr#/collection1/query,进行查询


将solr放到tomcat容器里面,,在此很少作介绍


ant编译nutch:切换到nutch目录:


http://news.163.com/

http://www.gov.cn/

http://www.sbsm.gov.cn/

http://news.stnn.cc/china/

http://www.zaobao.com/wencui/social

http://www.xinhuanet.com/politics/1.htm

http://news.china.com.cn/shehui/node_7185045.htm


bin/nutch inject xinwen -crawlId ee

bin/nutch  generate -topN 3   -crawlId ee

bin/nutch fetch -all   -crawlId ee

bin/nutch parse -all   -crawlId ee  

bin/nutch updatedb  -all -crawlId ee



./crawl seed.txt fanti http://localhost:8983/solr 2


http://172.16.2.29:8983/solr#/collection2/query


 bin/nutch readdb -dump /home/hadoop/get/20151210 -crawlId qq



+^http://([a-z0-9]*\.)*sohu.com



+^http://([a-z0-9]*\.)*.*





################################抓取更新###############################

修改nutch-site.xml 添加以下配置

<!-- 多长时间再抓取抓取以前抓过的页面,单位秒。默认30天 -->  

<property>  

    <name>db.fetch.interval.default</name>  

    <value>420480000</value>  

    <description>The default number of seconds between re-fetches of a page (30 days). 


 

    </description>  

</property>  

<!-- 多少时间后强制更新整个CrawlDB库 -->  

<property>  

    <name>db.fetch.interval.max</name>  

    <value>630720000</value>  

    <description>The maximum number of seconds between re-fetches of a page  

    (90 days). After this period every page in the db will be re-tried, no  

    matter what is its status.  

    </description>  

</property>  


##################### 模拟浏览器#######################################

在 nutch-site.xml 中只须要增长以下几种配置之一即可以 模拟 某一浏览器: 

一、模拟 Firefox 浏览器: 

<property>

<name>http.agent.name</name>

<value>Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko</value>

</property>

<property>

<name>http.agent.version</name>

<value>20100101 Firefox/27.0</value>

</property>

二、模拟 IE 浏览器:

<property>

<name>http.agent.name</name>

<value>Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident</value>

</property>

<property>

<name>http.agent.version</name>

<value>6.0)</value>

</property>

三、模拟 Chrome 浏览器: 

<property>

<name>http.agent.name</name>

<value>Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) 


Chrome/33.0.1750.117 Safari</value>

</property>

<property>

<name>http.agent.version</name>

<value>537.36</value>

</property>

相关文章
相关标签/搜索