1、下载solr4.8.1,上传至/home/hadoop
2、解压,重命名为solr
<span style="font-family:SimSun;font-size:18px;">unzip apache-solr-4.8.1.zip
mv apache-solr-4.8.1 solr</span>
3、把solr文件夹dist目录下面的solr-4.8.1.war,重命名为solr.war,然后复制到/usr/tomcat/webapps子目录下
<span style="font-family:SimSun;font-size:18px;">mv apache-solr-4.8.1.war solr.war
cp solr.war /usr/tomcat/webapps</span>
4、修改tomcat的server.xml,添加中文字符编码
修改前:
<span style="font-family:SimSun;font-size:18px;"> <Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" /></span>
修改后:
<span style="font-family:SimSun;font-size:18px;"> <Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreds="25"
enableLookups="false" acceptCount="100" disableUploadTimeout="true"
URIEncoding="UTF-8" useBodyEncodingForURI="true" /></span>
5、把/home/hadoop/solr/example,下面的solr目录,拷贝到/usr/tomcat目录下<span style="font-family:SimSun;font-size:18px;">cp /home/hadoop/solr/example/solr /usr/tomcat</span>
6、在/usr/tomcat/conf/Catalina/localhost目录下,创建solr.xml文件,内容如下:
<span style="font-family:SimSun;font-size:18px;"><?xml version="1.0" encoding="UTF-8"?>
<Context docBase="/usr/tomcat/webapps/solr.war" debug="0" crossContext="true" >
<Environment name="solr/home" type="java.lang.String" value="/usr/tomcat/solr" override="true" />
</Context></span>
7、整合nutch,将/home/hadoop/nutch/conf目录下面的schema.xml文件复制到/usr/tomcat/solr/collection1/conf文件夹下,将原来的备份8、配置nutch代理名称,/home/hadoop/nutch/conf文件夹下的nutch-site.xml,增加如下内容:
<configuration>
<property>
<name>http.agent.name</name>
<value>*</value>
</property>
</configuration>
9、在nutch创建种子文件夹urls
mkdir urls
10、在urls下面创建,待爬虫的文件seed.txt,并填写所爬网站
http://www.tuicool.com/topics/11020000
http://news.baidu.com
http://www.qq.com
http://guodo.net
http://www.pcauto.com.cn/
http://www.xcar.com.cn/
http://auto.sina.com.cn
11、在/usr/tomcat/solr/collection1/conf文件夹的schema.xml,添加
<field name="_version_" type="long" indexed="true" stored="true"/>
位置:
<field name="_version_" type="long" indexed="true" stored="true"/>
</fields>
<uniqueKey>id</uniqueKey>
12、在/home/hadoop/nutch/conf文件夹,配置regex-urlfilter.txt
原来
# accept anything else
# +.
改成
# accept anything else
+^
13、执行bin/crawl urls/seed.txt crawl http://localhost:8080/solr 2,即可创建索引