1.下載tomcatsolr
cd/app/download
wgethttp://mirrors.cnnic.cn/apache/lucene/solr/4.5.0/solr-4.5.0.zip
wgethttp://apache.dataguru.cn/tomcat/tomcat-7/v7.0.42/bin/apache-tomcat-7.0.42.tar.gz
2.解壓tomcatsolr
tarzxfache-tomcat-7.0.42.tar.gz
unzipsolr-4.5.0.zip
mvsolr-4.5.0/app/solr
3.部署Tomcat
cp-rapache-tomcat-7.0.40/*/app/tomcat_solr/
4.修改tomcat的server.xml配置文件,讓其支持中文.
<Connectorport="8000"protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"URIEncoding="UTF-8"/>
5.解壓縮solr.war至/app/tomcat_solr/webapps下
unzip/app/solr/example/webapps/solr.war-d/app/tomcat_solr/webapps/solr
6..拷貝/app/solr/example/lib/ext/下所有jar包至/app/tomcat_solr/webapps/solr/WEB-INF/lib/下,
將/app/solr/example/resources/log4j.properties拷貝到/app/tomcat_solr/lib下
cp/app/solr/example/lib/ext/*/app/tomcat_solr/webapps/solr/WEB-INF/lib/
cp/app/solr/example/resources/log4j.properties/app/tomcat_solr/lib/
7.修改solr下的web.xml,配置solrhome
vim/app/tomcat_solr/webapps/solr/WEB-INF/web.xml
<env-entry>
<env-entry-name>solr/home</env-entry-name>
<env-entry-value>/app/solr/example/solr</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
8.注意你的solrhome配置爲另一個新的目錄。需要修改collection1/conf/solrconfig.xml文件,讓其找到相應的文件。
vim/app/tomcat_solr/webapps/solr/collection1/conf/solrconfig.xml
<libdir="../../../contrib/extraction/lib"regex=".*\.jar"/>
<libdir="../../../dist/"regex="solr-cell-\d.*\.jar"/>
<libdir="../../../contrib/clustering/lib/"regex=".*\.jar"/>
<libdir="../../../dist/"regex="solr-clustering-\d.*\.jar"/>
<libdir="../../../contrib/langid/lib/"regex=".*\.jar"/>
<libdir="../../../dist/"regex="solr-langid-\d.*\.jar"/>
<libdir="../../../contrib/velocity/lib"regex=".*\.jar"/>
<libdir="../../../dist/"regex="solr-velocity-\d.*\.jar"/>
9.設置ik的中文分詞
解壓IKAnalyzer2012FF_hf1.zip,獲得IKAnalyzer2012FF_hf1.將該目錄下的IKAnalyzer.cfg.xml,IKAnalyzer2012FF_u1.jar,stopword.dic
放到之前安裝TOMCAT_HOME/webapps/solr/WEB-INF/lib/目錄下
修改vim/app/solr/example/solr/collection1/conf/schema.xml,在<type></types>中增加如下內容:
<fieldTypename="text_ik"class="solr.TextField">
<analyzertype="index"isMaxWordLength="false"class="org.wltea.analyzer.lucene.IKAnalyzer"/>
<analyzertype="query"isMaxWordLength="true"class="org.wltea.analyzer.lucene.IKAnalyzer"/>
</fieldType>
10.進入tomcat下的bin目錄
shstartup.sh