在 Tomcat 中启动 Solr 时出错

在 Tomcat 中启动 Solr 时出错

我刚刚安装了 Tomcat6,现在正在尝试安装 Solr 3.6.1。

我复制了.war 文件和示例 solr 目录。

cd apache-solr-3.6.1/dist
cp apache-solr-3.6.1.war /usr/share/tomcat6/webapps/solr.war
cp -r /usr/local/src/apache-solr-3.6.1/example/solr /usr/local/solr

cd /usr/share/tomcat6/webapps/solr/WEB-INF
nano web.xml

未注释<env-entry>...</env-entry>

<env-entry-value>...</env-entry-value>用。。。来代替<env-entry-value>/usr/local/solr</env-entry-value>

当我去http://domain.com:8080/solr我收到错误:

HTTP Status 500 - Severe errors in solr configuration. Check your log files for more detailed information on what may be wrong. If you want solr to continue after configuration errors, change: <abortOnConfigurationError>false</abortOnConfigurationError> in solr.xml ------------------------------------------------------------- java.lang.RuntimeException: java.io.IOException: Cannot create directory: /usr/local/solr/./data/index at org.apache.solr.core.SolrCore.initIndex(SolrCore.java:403) at org.apache.solr.core.SolrCore.<init>(SolrCore.java:552) at org.apache.solr.core.CoreContainer.create(CoreContainer.java:480) at org.apache.solr.core.CoreContainer.load(CoreContainer.java:332) at org.apache.solr.core.CoreContainer.load(CoreContainer.java:216) at org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:161) at org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:96) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295) at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3838) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4488) at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1251) at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:613) at org.apache.catalina.manager.HTMLManagerServlet.doGet(HTMLManagerServlet.java:136) at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:558) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:679) Caused by: java.io.IOException: Cannot create directory: /usr/local/solr/./data/index at org.apache.lucene.store.NativeFSLock.obtain(NativeFSLockFactory.java:171) at org.apache.lucene.store.Lock.obtain(Lock.java:72) at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:1098) at org.apache.solr.update.SolrIndexWriter.<init>(SolrIndexWriter.java:84) at org.apache.solr.core.SolrCore.initIndex(SolrCore.java:398) ... 29 more

发生了什么?我该如何解决这个问题?谢谢!

答案1

看起来您需要让 Tomcat 用户写入该/usr/local/solr目录。

根据您的操作系统和 Tomcat 的安装方式,使用的用户名和组会有所不同,但大致如下:

chown -R tomcat:tomcat /usr/local/solr

检查用户拥有什么/usr/share/tomcat6,这应该会为您指明正确的方向。

如果之后仍然失败,那么很可能是 SELinux 等备用访问控制机制存在问题。

答案2

我会检查文件夹 /usr/local/solr 的权限,因为日志文件基本上告诉您它无法在该路径中创建文件夹。

运行 Tomcat 的用户应该具有读取和写入 /usr/local/solr 及其子文件夹的权限。

相关内容