最近时间在研究solr,关于配置,在网上搜的资料基本上都是过时的,不适用,无奈只能去wiki上找原文。长话短说,现将配置的过程贴出来分享下。
原文的出处是:http://wiki.apache.org/solr/SolrTomcat
根据原文,由于“Configure Tomcat to recognize the solr home directory you created, by adding the Java Options -Dsolr.solr.home=c:\web\solr and -Dsolr.velocity.enabled=false ”这句话不是很明白。所以根据“
* Note: For Tomcat 7 and Solr3.4(last version on 2011-09-23), the above option on setenv.bat may not work, so you could not use it and put this code fragment
-
on $CATALINA_HOME/conf/Catalina/localhost/solr.xml
<?xml version="1.0" encoding="UTF-8"?> <Context docBase="C:\apache-tomcat-7.0.21\webapps\solr.war" debug="0" crossContext="true" > <Environment name="solr/home" type="java.lang.String" value="C:\solr" override="true" /> </Context>
solr的版本是4.8.1
中间件是Tomcat,版本是7.0.35
jdk版本需要是1.7
配置步骤:
1、下载solr、tomcat;
2、解压solr;
3、根据“
- Make the "solr home" directory called, where you intend the application server to function, say c:\web\solr\ ”新建solr home
4、根据“
- Copy the contents of the example\solr directory c:\temp\solrZip\example\solr\ to c:\web\solr\”把“解压路径\solr-4.8.1\example\solr”下的内容放置在solr home中
5、根据“
- Copy the *solr*.war file from c:\temp\solrZip\dist\ to the Tomcat webapps directory c:\tomcat\webapps\
- Rename the *solr*.war file solr.war ”把“解压路径\solr-4.8.1\dist”下的solr-4.8.1.war放置在tomcat安装路径下的webapps下,并重命名为solr.war
6、根据“
-
Note: For Tomcat 7 and Solr3.4(last version on 2011-09-23), the above option on setenv.bat may not work, so you could not use it and put this code fragment
on $CATALINA_HOME/conf/Catalina/localhost/solr.xml
<?xml version="1.0" encoding="UTF-8"?> <Context docBase="C:\apache-tomcat-7.0.21\webapps\solr.war" debug="0" crossContext="true" > <Environment name="solr/home" type="java.lang.String" value="C:\solr" override="true" /> </Context>
7、在生成的solr应用下需要新加入的包有:log4j-1.2.16.jar、slf4j-api-1.7.6.jar、slf4j-log4j12-1.7.6.jar、jcl-over-slf4j-1.7.6.jar、jul-to-slf4j-1.7.6.jar
8、至此配置就完成了
以上是配置的整个过程,最后访问solr的admin.html文件能够得到正确的结果。