Solr学习笔记-在Tomcat上部署运行Solr,solrtomcat
Solr学习笔记-在Tomcat上部署运行Solr,solrtomcat
上一篇我们初识了Solr并且学习了Jetty的启动方式,查看了Solr的管理界面,这一篇我们来实现在Tomcat上部署运行Solr。
部署环境:
window7
jdk1.6.0_14
Solr-4.7.2
tomcat-6.0.37
Solr的安装配置Solr home ,主要介绍基于JNDI的配置,其它方式可以参考Solr的wiki。
基于JNDI配置
1:首先建立一个Solr的运行目录。
C:\solr-tomcat
将解压缩包中的D:\work\work-tools\solr\solr-4.7.2\solr-4.7.2\example\下的solr目录拷贝到C:\solr-tomcat下。
2:建立JNDI文件
在tomcat的D:\work\work-tools\webserver\tomcat-6.0.37\conf\Catalina\localhost下面创建solr.xml文件。
内容如下:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Context docBase="D:\work\work-tools\webserver\tomcat-6.0.37\webapps\solr.war" debug="0" crossContext="true" > ? <Environment name="solr/home" type="java.lang.String" value="C:\solr-tomcat\solr" override="true" /> </Context>
3:修改server.xml的URI编码
在tomcat的D:\work\work-tools\webserver\tomcat-6.0.37\conf下编辑server.xml
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" />
4:部署solr.war包
把D:\work\work-tools\solr\solr-4.7.2\solr-4.7.2\dist下的solr-4.7.2.war修改为solr.war拷贝到D:\work\work-tools\webserver\tomcat-6.0.37\webapp下。
5:配置日志
这一步很关键,如果不配置会出现以下错误
Error filterStart
Context [/solr] startup failed due to previous errors
在这里看不出到底出现了什么错误,大致只知道在启动Context /solr的时候,之前有配置出现了错误,但是什么配置我们不知道,这时候可以查看一下tomcat的\tomcat-6.0.37\logs目录下查看localhost.2014-08-23.log日志,我们会看到详细出错信息。
严重: Exception starting filter SolrRequestFilter java.lang.NoClassDefFoundError: Failed to initialize Apache Solr: Could not find necessary SLF4j logging jars. If using Jetty, the SLF4j logging jars need to go in the jetty lib/ext directory. For other containers, the corresponding directory should be used. For more information, see: http://wiki.apache.org/solr/SolrLogging
这里说的很清楚是SLF4J的jar没有,我们到solr-4.7.2\example\lib\ext下把所有的包都考到tomcat\lib目录下。
6:启动tomcat
6:查看solr的admin页面http://127.0.0.1:8080/solr
总结:这些配置在solr的wiki上都有说明,并且都按照linux和windows分类,其实solr真正的生产环境还是要部署在linux上的,因为Solr提供了一些用于测试及管理、维护较为方便的shell脚本,这样在linux运维solr是非常方便的。
注:wiki地址http://wiki.apache.org/solr/SolrTomcat
我知道的大概有以下这么几种方式
1.在eclipse里搭好了solr的项目,部署到窗口时,先配置运行参数
2.如果你的容器是tomcat,可以修改catalina.bat文件,在第一行加上如下参数
在web-inf里加两个文件:
WEB-INF/ibm-web-bnd.xmi
WEB-INF/ibm-web-ext.xmi
ibm-web-bnd.xmi
<?xml version="1.0" encoding="UTF-8"?><webappbnd:WebAppBinding xmi:version="2.0" xmlns:xmi="www.omg.org/XMI" xmlns:webappbnd="webappbnd.xmi" xmi:id="WebAppBinding_1213147492785" virtualHostName="default_host"> <webapp href="WEB-INF/web.xml#WebApp_ID"/></webappbnd:WebAppBinding>ibm-web-ext.xmi
<?xml version="1.0" encoding="UTF-8"?><webappext:WebAppExtension xmi:version="2.0" xmlns:xmi="www.omg.org/XMI" xmlns:webappext="webappext.xmi" xmi:id="WebAppExtension_1213147492785" reloadInterval="3" reloadingEnabled="true" additionalClassPath="" fileServingEnabled="true" directoryBrowsingEnabled="false" serveServletsByClassnameEnabled="true"> <webApp href="WEB-INF/web.xml#WebApp_ID"/> <jspAttributes xmi:id="JSPAttribute_1" name="jdkSourceLevel" value="15"/></webappext:WebAppExtension>在web.xml里加
... <welcome-file-list> <welcome-file>index.jsp</welcome-file> ......余下全文>>
评论暂时关闭