Solr DataImportHandler configuration



我想在DataImportHandler的帮助下从mysql数据库中获取数据,这样我就可以创建索引。现在我已经配置了我的 Solr 实例,以便它可以在 Tomcat(示例管理页面)上运行,但是如果我尝试更改 sorlconfig.xml 文件,我会收到错误消息。我正在使用 Solr 3.6

所以我的配置是:

在 solrconfig 中.xml我添加了:

<dataDir>${solr.data.dir:/usr/share/tomcat7/solr2}</dataDir>

指定我的工作目录

然后

<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">/usr/share/tomcat7/solr2/conf/data-config.xml</str> 
</lst>
</requestHandler>

以指定新的请求处理程序。

这两个是我对 DIH 的 lib 指令。我需要更改它们吗?

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

我还创建了data-config.xml文件并添加了以下内容:

<?xml version="1.0" encoding="UTF-8"?>
<dataConfig>
<dataSource   type="JdbcDataSource"
              driver="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost:3306/ethicsweb_experts"
              user="root"
              password=""/>
<document>
       <entity name="experts" datasource="mysql" pk="mainid"
              query="SELECT experts.mainid as mainid FROM experts WHERE validRec = 'y'">
        <field column="mainid" name="mainid"/>
        <field column="validRec" name="validRec"/>
    </entity>
</document>

我已经将以下jar复制到tomcat/lib文件夹(DIH jar文件和mysql JDBC连接器jar文件)

apache-solr-dataimporthandler-3.6.0.jar
apache-solr-dataimporthandler-extras-3.6.0.jar
mysql-connector-java-5.1.20-bin.jar

同样在架构.xml文件中,我添加了以下字段:

<field name="mainid" type="int" indexed="true" stored="true"  />
<field name="validRec" type="string" indexed="true" stored="true" />
<field name="recSource" type="string" indexed="true" stored="true" />
<uniqueKey>mainid</uniqueKey>

但是现在当我尝试访问时:

http://localhost:8080/solr2/ 

我得到以下输出:

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 ------------------------------------------------------------- 
org.apache.solr.common.SolrException: No cores were created, please check the logs for errors at org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:172) 
at org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:96) 
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:277) 
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382) 
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:103) 
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4638) 
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5294)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895) 
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871) 
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615) 
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:649) 
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1585) 
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:1110) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) 
at java.lang.Thread.run(Thread.java:722)
 -------------------------------------------------------------         
java.lang.NoClassDefFoundError: org/apache/solr/util/plugin/SolrCoreAware 
at java.lang.ClassLoader.defineClass1(Native Method) 
at java.lang.ClassLoader.defineClass(ClassLoader.java:791) 
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) 
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) 
at java.net.URLClassLoader.access$100(URLClassLoader.java:71) 
at java.net.URLClassLoader$1.run(URLClassLoader.java:361) 
at java.net.URLClassLoader$1.run(URLClassLoader.java:355) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.net.URLClassLoader.findClass(URLClassLoader.java:354) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:423) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:356) 
at java.lang.Class.forName0(Native Method) 
at java.lang.Class.forName(Class.java:264) 
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1698) 
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:264) 
at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:378) 
at org.apache.solr.core.SolrCore.createInstance(SolrCore.java:419) 
at org.apache.solr.core.SolrCore.createRequestHandler(SolrCore.java:455) 
at org.apache.solr.core.RequestHandlers.initHandlersFromConfig(RequestHandlers.java:159) 
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:563) 
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:483) 
at org.apache.solr.core.CoreContainer.load(CoreContainer.java:335) 
at org.apache.solr.core.CoreContainer.load(CoreContainer.java:219) 
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.initFilter(ApplicationFilterConfig.java:277) 
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258) 
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382) 
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:103) 
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4638) 
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5294) 
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895) 
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871) 
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615) 
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:649) 
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1585) 
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:1110) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) 
at java.lang.Thread.run(Thread.java:722) Caused by: java.lang.ClassNotFoundException: org.apache.solr.util.plugin.SolrCoreAware 
at java.net.URLClassLoader$1.run(URLClassLoader.java:366) 
at java.net.URLClassLoader$1.run(URLClassLoader.java:355) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.net.URLClassLoader.findClass(URLClassLoader.java:354) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:423) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:356) ... 47 more

我的日志条目显示:

SEVERE: java.lang.NoClassDefFoundError: org/apache/solr/util/plugin/SolrCoreAware
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1698)
    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:264)
    at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:378)
    at org.apache.solr.core.SolrCore.createInstance(SolrCore.java:419)
    at org.apache.solr.core.SolrCore.createRequestHandler(SolrCore.java:455)
    at org.apache.solr.core.RequestHandlers.initHandlersFromConfig(RequestHandlers.java:159)
    at org.apache.solr.core.SolrCore.<init>(SolrCore.java:563)
    at org.apache.solr.core.CoreContainer.create(CoreContainer.java:483)
    at org.apache.solr.core.CoreContainer.load(CoreContainer.java:335)
    at org.apache.solr.core.CoreContainer.load(CoreContainer.java:219)
    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.initFilter(ApplicationFilterConfig.java:277)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258)
    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:103)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4638)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5294)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:649)
    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1585)
    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:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ClassNotFoundException: org.apache.solr.util.plugin.SolrCoreAware
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    ... 47 more
Jun 15, 2012 4:07:50 PM org.apache.solr.servlet.SolrDispatchFilter init
SEVERE: Could not start Solr. Check solr/home property and the logs
org.apache.solr.common.SolrException: No cores were created, please check the logs for errors
    at org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:172)
    at org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:277)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258)
    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:103)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4638)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5294)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:649)
    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1585)
    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:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
Jun 15, 2012 4:07:50 PM org.apache.solr.common.SolrException log
SEVERE: org.apache.solr.common.SolrException: No cores were created, please check the logs for errors
    at org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:172)
    at org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:277)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258)
    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:103)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4638)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5294)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:649)
    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1585)
    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:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

所以现在我想知道我在哪里搞砸了DataImportHandler的配置。是否需要指定更多 jar 文件?我是否将 jar 文件放在正确的目录中? 任何帮助将不胜感激。

这里的问题是您的"lib"条目与 jar 文件位置未正确定义。

根据您的 solr.home 条目,这些 dist 的、contrib 文件夹无法解析。 例如,您可能需要额外的"../"为此..

好的,我已经为同样的问题斗争了几个小时。solr 3.4 书没有涵盖 DIH 的设置。

将 lib 文件夹保留原样,位于示例文件夹中。在 example/solr 中创建一个名为 lib 的新文件夹。打开示例/solr/solr.xml其中配置了内核并添加 sharedLib 属性

<solr persistent="false" sharedLib="./lib">

你所有的溶胶罐都倒在这里!solr 没有从 lib 文件夹中加载它们存在一些冲突问题,我认为这是针对码头库的......但我不确定。

服务器

提取的 war 文件lib目录中没有这些 DIH 驱动程序。将其添加到其中,这可能会解决您的问题。

我为此奋斗了 5 个小时,现在它开始工作了。

相关内容

  • 没有找到相关文章

最新更新