操作环境: Win8 / Ubuntu64(最下面), Tomcat7, Solr4.4, Jdk7
En More : http://wiki.apache.org/solr/SolrTomcat
1) 在apache官网下载solr4.4的包,解压到本地目录,如E:\apache\solr-4.4.0
2) 找一个目录作为solr的home目录,如D:/WebContainer/apache-solr-home
3) 解压tomcat7,到bin先运行startup.bat,确保tomcat正常运行和访问,关闭tomcat
4) 复制E:\apache\solr-4.4.0\example\solr目录下的所有文件到D:/WebContainer/apache-solr-home
5) 复制E:\apache\solr-4.4.0\dist目录下solr-4.4.0.war包到D:/WebContainer/apache-solr-home,再对solr-4.4.0.war解压solr-4.4.0, 重命名solr-4.4.0为solr.
6) 在tomcat\conf\Catalina\localhost目录下新增solr.xml,内容如下:
7) 把solr-4.4.0\example\lib\ext下的lib包全部复制到tomcat\lib下
8) 启动tomcat,访问http://localhost:8080/solr/
在配置的过程中, 发生一些错误.
solr - org.apache.solr.common.SolrException: Could not load config for solrconfig.xml
在这里再添加一步, 在solr\WEB-INF\web.xml修改
去掉注释:
修改为:
solr/home D:/WebContainer/apache-solr-home/solr java.lang.String
9) 再重启Tomcat. http://localhost:8080/solr/
在ubuntu下面安装Solr 4.4 请参见比较新的一篇文章:
Install Apache Solr 4.4 on Ubuntu 12.04 with Tomcat 7 and MySql Data Import
by Greg Somers | 30/07/2013
http://gregsomers.com/blog/2013/07/30/install-apache-solr-44-on-ubuntu-1204-with-tomcat-7-and-mysql-data-import
附加说明:在我安装后,出现了异常信息:
ERROR - 2013-09-04 14:19:20.693; org.apache.solr.common.SolrException; null:org.apache.solr.common.SolrException: SolrCore 'collection1' is not available due to init failure: Could not load config for solrconfig.xml at org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:860) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:251) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:158) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:724) Caused by: org.apache.solr.common.SolrException: Could not load config for solrconfig.xml at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:592) at org.apache.solr.core.CoreContainer.create(CoreContainer.java:657) at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:364) at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:356) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) ... 3 more Caused by: java.io.IOException: Can't find resource 'solrconfig.xml' in classpath or '/home/web/solr-env/collection1/conf/', cwd=/home/web/tomcat-7.0.42/bin at org.apache.solr.core.SolrResourceLoader.openResource(SolrResourceLoader.java:322) at org.apache.solr.core.SolrResourceLoader.openConfig(SolrResourceLoader.java:287) at org.apache.solr.core.Config.发现找不到solrconfig.xml文件(Config.java:116) at org.apache.solr.core.Config. (Config.java:86) at org.apache.solr.core.SolrConfig. (SolrConfig.java:120) at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:589) ... 11 more