配置solr过程中遇到的问题及解决方案



1.由于缺少solr源文件报错

2018/1/9 上午10:56:59 WARN SolrResourceLoader Can't find (or read) directory to add to classloader: ../../../contrib/extraction/lib (resolved as: /usr/local/solrhome/coll/../../../contrib/extraction/lib).
2018/1/9 上午10:56:59 WARN SolrResourceLoader Can't find (or read) directory to add to classloader: ../../../dist/ (resolved as: /usr/local/solrhome/coll/../../../dist).
2018/1/9 上午10:56:59 WARN SolrResourceLoader Can't find (or read) directory to add to classloader: ../../../contrib/clustering/lib/ (resolved as: /usr/local/solrhome/coll/../../../contrib/clustering/lib).
2018/1/9 上午10:56:59 WARN SolrResourceLoader Can't find (or read) directory to add to classloader: ../../../dist/ (resolved as: /usr/local/solrhome/coll/../../../dist).
2018/1/9 上午10:56:59 WARN SolrResourceLoader Can't find (or read) directory to add to classloader: ../../../contrib/langid/lib/ (resolved as: /usr/local/solrhome/coll/../../../contrib/langid/lib).
2018/1/9 上午10:56:59 WARN SolrResourceLoader Can't find (or read) directory to add to classloader: ../../../dist/ (resolved as: /usr/local/solrhome/coll/../../../dist).
2018/1/9 上午10:56:59 WARN SolrResourceLoader Can't find (or read) directory to add to classloader: ../../../contrib/velocity/lib (resolved as: /usr/local/solrhome/coll/../../../contrib/velocity/lib).
2018/1/9 上午10:56:59 WARN SolrResourceLoader Can't find (or read) directory to add to classloader: ../../../dist/ (resolved as: /usr/local/solrhome/coll/../../../dist).
2018/1/9 上午10:56:59 WARN SolrResourceLoader Can't find (or read) directory to add to classloader: ../../../contrib/extraction/lib (resolved as: /usr/local/solrhome/collection1/../../../contrib/extraction/lib).
2018/1/9 上午10:56:59 WARN SolrResourceLoader Can't find (or read) directory to add to classloader: ../../../dist/ (resolved as: /usr/local/solrhome/collection1/../../../dist).
2018/1/9 上午10:56:59 WARN SolrResourceLoader Can't find (or read) directory to add to classloader: ../../../contrib/clustering/lib/ (resolved as: /usr/local/solrhome/collection1/../../../contrib/clustering/lib).
2018/1/9 上午10:56:59 WARN SolrResourceLoader Can't find (or read) directory to add to classloader: ../../../dist/ (resolved as: /usr/local/solrhome/collection1/../../../dist).
2018/1/9 上午10:56:59 WARN SolrResourceLoader Can't find (or read) directory to add to classloader: ../../../contrib/langid/lib/ (resolved as: /usr/local/solrhome/collection1/../../../contrib/langid/lib).
2018/1/9 上午10:56:59 WARN SolrResourceLoader Can't find (or read) directory to add to classloader: ../../../dist/ (resolved as: /usr/local/solrhome/collection1/../../../dist).
2018/1/9 上午10:56:59 WARN SolrResourceLoader Can't find (or read) directory to add to classloader: ../../../contrib/velocity/lib (resolved as: /usr/local/solrhome/collection1/../../../contrib/velocity/lib).
2018/1/9 上午10:56:59 WARN SolrResourceLoader Can't find (or read) directory to add to classloader: ../../../dist/ (resolved as: /usr/local/solrhome/collection1/../../../dist).
2018/1/9 上午10:57:00 WARN RequestHandlers Multiple requestHandler registered to the same name: /update ignoring: org.apache.solr.handler.UpdateRequestHandler
2018/1/9 上午10:57:00 WARN RequestHandlers Multiple requestHandler registered to the same name: /update ignoring: org.apache.solr.handler.UpdateRequestHandler

解决方法是把solr源文件包里面的文件夹contrib和dist复制到solrhome里的core的conf目录下就行了。

我的命令:  进入solr软件的根目录  (这个solr目录不是tomcat里的solr目录,我的目录为 /home/hadoop/solr/  )

    cp -rf contrib/   /usr/tomcat/solr/collection1/conf/

   cp -rf dist/   /usr/tomcat/solr/collection1/conf/   

并修改   tomcat/solr/collection1/conf/solrconfig.xml 文件


默认配置文件:
  <lib dir="../../../contrib/extraction/lib" regex=".*\.jar" />
  <lib dir="../../../dist/" regex="solr-cell-\d.*\.jar" />

  <lib dir="../../../contrib/clustering/lib/" regex=".*\.jar" />
  <lib dir="../../../dist/" regex="solr-clustering-\d.*\.jar" />

  <lib dir="../../../contrib/langid/lib/" regex=".*\.jar" />
  <lib dir="../../../dist/" regex="solr-langid-\d.*\.jar" />

  <lib dir="../../../contrib/velocity/lib" regex=".*\.jar" />
  <lib dir="../../../dist/" regex="solr-velocity-\d.*\.jar" />


修改成自己相应的路径。


2.由于缺少mmseg4j库文件报错如下:

org.apache.solr.common.SolrException: Plugin init failure for [schema.xml] fieldType "text_cn": Plugin init failure for [schema.xml] analyzer/tokenizer: Error loading class ’com.chenlb.mmseg4j.solr.MMSe
gTokenizerFactory’
at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:177)
at org.apache.solr.schema.IndexSchema.readSchema(IndexSchema.java:476)
at org.apache.solr.schema.IndexSchema.<init>(IndexSchema.java:176)
at org.apache.solr.schema.ClassicIndexSchemaFactory.create(ClassicIndexSchemaFactory.java:62)
at org.apache.solr.schema.IndexSchemaFactory.buildIndexSchema(IndexSchemaFactory.java:36)
at org.apache.solr.core.CoreContainer.createFromZk(CoreContainer.java:893)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:982)
at org.apache.solr.core.CoreContainer$2.call(CoreContainer.java:597)
at org.apache.solr.core.CoreContainer$2.call(CoreContainer.java:592)
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)
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:722)
Caused by: org.apache.solr.common.SolrException: Plugin init failure for [schema.xml] analyzer/tokenizer: Error loading class ’com.chenlb.mmseg4j.solr.MMSegTokenizerFactory’
at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:177)
at org.apache.solr.schema.FieldTypePluginLoader.readAnalyzer(FieldTypePluginLoader.java:362)
at org.apache.solr.schema.FieldTypePluginLoader.create(FieldTypePluginLoader.java:86)
at org.apache.solr.schema.FieldTypePluginLoader.create(FieldTypePluginLoader.java:43)
at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:151)
... 16 more
Caused by: org.apache.solr.common.SolrException: Error loading class ’com.chenlb.mmseg4j.solr.MMSegTokenizerFactory’
at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:464)
at org.apache.solr.core.SolrResourceLoader.newInstance(SolrResourceLoader.java:558)
at org.apache.solr.schema.FieldTypePluginLoader$2.create(FieldTypePluginLoader.java:342)
at org.apache.solr.schema.FieldTypePluginLoader$2.create(FieldTypePluginLoader.java:335)
at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:151)
... 20 more
解决方法是

下载mmseg4j包放到solr工程目录库中比如我的是/home/apache-tomcat-6.0.37/webapps/solr/WEB-INF/lib/

下载地址:https://code.google.com/p/mmseg4j/downloads/list

solr4.0以下版本请下载mmseg4j1.8.5以下版本,解压后复制文件mmseg4j-all-1.8.5.jar到apache-tomcat-6.0.37/webapps/solr/WEB-INF/lib/下面

solr4.0以上版本请下载mmseg4j1.9.0以上版本,解压后复制文件mmseg4j-analysis-1.9.1.jar  mmseg4j-core-1.9.1.jar  mmseg4j-solr-1.9.1.jar到apache-tomcat-6.0.37/webapps/solr/WEB-INF/lib/下面

然后重新启动tomcat即可解决。

如果版本不按上面说的配置有可能报下面的错误:

4727 [coreLoadExecutor-4-thread-1] ERROR org.apache.solr.core.CoreContainer  ?.null:java.lang.NoClassDefFoundError: org/apache/solr/analysis/BaseTokenizerFactory
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2854)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
at java.lang.ClassLoader.loadClass(ClassLoader.java:410)
at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:789)
at java.lang.ClassLoader.loadClass(ClassLoader.java:410)
at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:789)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:266)
at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:448)
at org.apache.solr.core.SolrResourceLoader.newInstance(SolrResourceLoader.java:558)
at org.apache.solr.schema.FieldTypePluginLoader$2.create(FieldTypePluginLoader.java:342)
at org.apache.solr.schema.FieldTypePluginLoader$2.create(FieldTypePluginLoader.java:335)
at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:151)
at org.apache.solr.schema.FieldTypePluginLoader.readAnalyzer(FieldTypePluginLoader.java:362)
at org.apache.solr.schema.FieldTypePluginLoader.create(FieldTypePluginLoader.java:86)
at org.apache.solr.schema.FieldTypePluginLoader.create(FieldTypePluginLoader.java:43)
at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:151)
at org.apache.solr.schema.IndexSchema.readSchema(IndexSchema.java:476)
at org.apache.solr.schema.IndexSchema.<init>(IndexSchema.java:176)
at org.apache.solr.schema.ClassicIndexSchemaFactory.create(ClassicIndexSchemaFactory.java:62)
at org.apache.solr.schema.IndexSchemaFactory.buildIndexSchema(IndexSchemaFactory.java:36)
at org.apache.solr.core.CoreContainer.createFromZk(CoreContainer.java:893)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:982)
at org.apache.solr.core.CoreContainer$2.call(CoreContainer.java:597)
at org.apache.solr.core.CoreContainer$2.call(CoreContainer.java:592)
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)
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:722)
Caused by: java.lang.ClassNotFoundException: org.apache.solr.analysis.BaseTokenizerFactory
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
... 38 more
这是因为4.0以上的版本要适配mmseg4j1.9.0以上版本

3.由于solr找不到数据文件报错

[http-8080-1] ERROR org.apache.solr.servlet.SolrDispatchFilter  ?.null:org.apache.solr.common.SolrException: SolrCore ’collection1’ is not available due to init failure: Plugin init failure for 

请检查放在solrhome下面的配置文件solr.xml

  <cores adminPath="/admin/cores" defaultCoreName="collection1" host="${host:172.18.84.57}" hostPort="${jetty.port:8080}" hostContext="${hostContext:solr}" zkClientTimeout="${zkClientTimeout:15000}">
    <core name="collection1" instanceDir="collection1" />
  </cores>
标红的是您的core文件夹名称,确认和实际的一样,一般在这个文件夹下面:

[root@solr solr]# pwd
/home/apache-tomcat-6.0.37/solrhome/solr
[root@solr solr]# ls
backup  bin  collection1  README.txt  solr.xml  zoo.cfg
修改成一致并确保有权限读取和执行就行。

4.应该注意的是要把solr源文件里面的jar包尽量都复制到apache-tomcat-6.0.37/webapps/solr/WEB-INF/lib/下面以免由于缺少jar包而无法正常运行。

总结:遇到问题一个一个的解决不怕问题多就怕你没思路。要冷静对待一个一个的突破,按照自己的思路一个一个来再蛋疼的问题都能解决。

展开阅读全文

没有更多推荐了,返回首页