您的位置:首页 > 运维架构 > Tomcat

solr入门之环境搭建-tomcat服务发布(单机版)

2016-05-12 23:40 633 查看


tomcat-one
在tomcat下发布solr示例项目,同样使用solr-4.9.1版本,下载solr-4.9.1.zip这个包
下载地址:http://lucene.apache.org/solr/mirrors-solr-latest-redir.html
Tomcat服务器部署solr示例(Tomcat单机版)

1)准备tomcat,这里使用的是apache-tomcat-7.0.68版本

2)取出solr解压目录下的\example\webapps\solr.war,放到Tomcat的webapps下,启动Tomcat,tomcat会自动加载solr.war解压为solr项目,solr.war相同目录位置会出现同名解压后的项目目录solr
3)在solr项目根目录下新建solr_home目录,将solr-4.9.1.zip解压后的..\example\solr目录下的内容全部拷贝到solr_home目录下(不做此步,会报错误:500 - {msg=SolrCore 'collection1' is not available due to init failure)

然后在项目中指定solr_home地址,有两种方式,一种是在web.xml中配置listener,并自己写listener程序(代码在其他文章中补充),这里采用第二种,直接在web.xml中配置:
在solr项目的web.xml中,放开env-entry,指定solr_home的
directly
<env-entry>
<env-entry-name>solr/home</env-entry-name>   
<env-entry-value>E:/solr/tomcat-one/apache-tomcat-7.0.68/webapps/solr/solr_home</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>


(不指定solr_home目录,会报如下错误:java.io.IOException: Can't find resource 'solrconfig.xml' in classpath or 'E:\solr\tomcat-one\apache-tomcat-7.0.68\bin\solr\collection1\conf'

4)将..\example\lib\ext下的所有包拷贝到solr项目的WEB-INF/lib目录下(如果不做此步会报错误:Could not find necessary SLF4j logging jars)
5)将..\example\resources目录下的log4j.properties拷贝到solr项目的classes目录下(因为没有自动建立日志文件,所以需要自己手动添加)
然后启动Tomcat,tomcat正常运行,浏览器访问地址:http://localhost:8080/solr(使用tomcat默认端口号8080),出现solr页面,有一个默认的collection1。
如果还想手动新建core,参照下篇:solr手动创建core
一般的时候,我们会比较习惯在web项目中来发布,所以,这个再费点事,将solr搭建为web项目,参照:eclipse下将solr发布为web项目
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: