第一步安装JDK
版本:jdk-6u45-linux-x64-rpm.bin
#mkdir /usr/java
#cd /usr/java
#wget jdk-6u45-linux-x64-rpm.bin
#sh jdk-6u45-linux-x64-rpm.bin
第二步安装Tomcat
#mkdir /usr/local/tomcat
#cd /usr/local/tomcat
#wget http://mirror.esocc.com/apache/tomcat/tomcat-7/v7.0.42/bin/apache-tomcat-7.0.42.tar.gz
#tar zxvf apache-tomcat-7.0.42.tar.gz
第三步安装solr
#mkdir /usr/local/solr
#cd /usr/local/solr
#wget http://apache.fayea.com/apache-mirror/lucene/solr/4.5.0/solr-4.5.0.tgz
#tar zxvf solr-4.5.0.tgz
第四步配置环境变量
# vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.6.0_45/
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export LASSPATH=.:/usr/java/jdk1.6.0_25/lib:/usr/java/jdk1.6.0_25/jre/lib:$CLASSPATH
export TOMCAT_HOME=/usr/local/tomcat/apache-tomcat-7.0.42
export JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=/usr/local/solr/solr"
第五步配置solr
#cp /usr/local/solr/solr-4.5.0/dist/solr-4.5.0.war /usr/local/apache-tomcat-7.0.42/tomcat/webapps/solr.war
#mkdir –p /usr/local/tomcat/conf/Catalina/localhost
#vi /usr/local/tomcat/conf/Catalina/localhost/solr.xml
<?xml version="1.0" encoding="utf-8"?>
<Context docBase="/usr/local/tomcat/webapps/solr.war" debug="0" crossContext="true" >
<Environment name="solr/home" type="java.lang.String" value="/usr/local/solr/example/solr" override="true" />
</Context>
第六步:
cp /usr/local/solr/solr-4.5.0/example/lib/ext/*.jar /usr/local/tomcat/apache-tomcat-7.0.42/lib/
cp /usr/local/solr/solr-4.5.0/example/resources/log4j.properties /usr/local/tomcat/apache-tomcat-7.0.42/lib/
第七步:启动tomcat
访问http://localhost:8080/solr 看到管理界面及配置成功。
可以设置保存索引文件的路径,这些都是在solr的实例中进行修改.
修改tomcat/solrapp/solr/collection/conf/中的solrconfig.xml,在里面修改路径
设置ik的中文分词
解压IK Analyzer 2012FF_hf1.zip,获得IK Analyzer 2012FF_hf1.将该目录下的IKAnalyzer.cfg.xml,IKAnalyzer2012FF_u1.jar,stopword.dic
放到之前安装TOMCAT_HOME/webapps/solr/WEB-INF/lib/目录下
修改tomcat/solrapp/solr/collection1/conf/中的schema.xml,在中增加如下内容:
conf/server.xml
#优化容器的连接数等信息
<Connector port="8083" protocol="org.apache.coyote.http11.Http11Protocol"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8"
minSpareThreads="20"
maxThreads="2000"
acceptCount="2000"
enableLookups="false"
disableUploadTimeout="true"
acceptorThreadCount="2"
/>