Solr学习笔记 在Tomcat上部署运行Solr

上一篇咱们初识了Solr而且学习了Jetty的启动方式,查看了Solr的管理界面,这一篇咱们来实如今Tomcat上部署运行Solr。html

部署环境:java

window7linux

jdk1.6.0_14web

Solr-4.7.2shell

tomcat-6.0.37apache

Solr的安装配置Solr home ,主要介绍基于JNDI的配置,其它方式能够参考Solr的wiki。

基于JNDI配置windows

1:首先创建一个Solr的运行目录。tomcat

C:\solr-tomcatapp

将解压缩包中的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文件。

内容以下:

view sourceprint?

1.<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

2.<Context docBase="D:\work\work-tools\webserver\tomcat-6.0.37\webapps\solr.war" debug="0" crossContext="true" >

3.? <Environment name="solr/home" type="java.lang.String" value="C:\solr-tomcat\solr" override="true" />

4.</Context>


3:修改server.xml的URI编码

在tomcat的D:\work\work-tools\webserver\tomcat-6.0.37\conf下编辑server.xml

view sourceprint?

1.<Connector port="8080" protocol="HTTP/1.1"

2.              connectionTimeout="20000"

3.              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日志,咱们会看到详细出错信息。

view sourceprint?

1.严重: Exception starting filter SolrRequestFilter

2.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

相关文章
相关标签/搜索