有没有办法修复solr索引

时间:2017-06-20 14:47:35

标签: solr

我正在运行一个抓取网络并将数据保存到solr索引的程序。由于神秘的原因,solr服务器崩溃了。现在我最终得到一个没有分段文件的损坏的索引,因此有可能失去我收集的所有数据5天....

当您尝试搜索此索引时,错误消息如下所示。索引文件夹肯定有数据,因为它有182个文件和2GB大小。

我曾尝试使用CheckIndex,但是没有关于没有段文件的错误......

java.util.concurrent.ExecutionException: org.apache.solr.common.SolrException: Unable to create core [chase]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at org.apache.solr.core.CoreContainer.lambda$load$6(CoreContainer.java:586)
    at com.codahale.metrics.InstrumentedExecutorService$InstrumentedRunnable.run(InstrumentedExecutorService.java:176)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.apache.solr.common.util.ExecutorUtil$MDCAwareThreadPoolExecutor.lambda$execute$0(ExecutorUtil.java:229)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.solr.common.SolrException: Unable to create core [chase]
    at org.apache.solr.core.CoreContainer.create(CoreContainer.java:935)
    at org.apache.solr.core.CoreContainer.lambda$load$5(CoreContainer.java:558)
    at com.codahale.metrics.InstrumentedExecutorService$InstrumentedCallable.call(InstrumentedExecutorService.java:197)
    ... 5 more
Caused by: org.apache.solr.common.SolrException: Error opening new searcher
    at org.apache.solr.core.SolrCore.<init>(SolrCore.java:977)
    at org.apache.solr.core.SolrCore.<init>(SolrCore.java:830)
    at org.apache.solr.core.CoreContainer.create(CoreContainer.java:920)
    ... 7 more
Caused by: org.apache.solr.common.SolrException: Error opening new searcher
    at org.apache.solr.core.SolrCore.openNewSearcher(SolrCore.java:2069)
    at org.apache.solr.core.SolrCore.getSearcher(SolrCore.java:2189)
    at org.apache.solr.core.SolrCore.initSearcher(SolrCore.java:1071)
    at org.apache.solr.core.SolrCore.<init>(SolrCore.java:949)
    ... 9 more
Caused by: org.apache.lucene.index.IndexNotFoundException: no segments* file found in LockValidatingDirectoryWrapper(NRTCachingDirectory(MMapDirectory@/home/zqz/Work/chase/aws/data/solr/chase/data/index lockFactory=org.apache.lucene.store.NativeFSLockFactory@51b2fc7e; maxCacheMB=48.0 maxMergeSizeMB=4.0)): files: [_fh2.fdt, _fh2.fdx, _fh2.fnm, _fh2.nvd, _fh2.nvm, _fh2.si, _fh2_Lucene50_0.doc, _fh2_Lucene50_0.pos, _fh2_Lucene50_0.tim, _fh2_Lucene50_0.tip, write.lock]
    at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:925)
    at org.apache.solr.update.SolrIndexWriter.<init>(SolrIndexWriter.java:118)
    at org.apache.solr.update.SolrIndexWriter.create(SolrIndexWriter.java:93)
    at org.apache.solr.update.DefaultSolrCoreState.createMainIndexWriter(DefaultSolrCoreState.java:248)
    at org.apache.solr.update.DefaultSolrCoreState.getIndexWriter(DefaultSolrCoreState.java:122)
    at org.apache.solr.core.SolrCore.openNewSearcher(SolrCore.java:2030)
    ... 12 more
2017-06-20 14:38:52.428 INFO  (qtp475266352-16) [   ] o.a.s.c.TransientSolrCoreCacheDefault Allocating transient cache for 2147483647 transient cores
2017-06-20 14:38:52.894 INFO  (qtp475266352-13) [   ] o.a.s.s.HttpSolrCall [admin] webapp=null path=/admin/cores params={indexInfo=false&wt=json&_=1497969532681} status=0 QTime=11
2017-06-20 14:38:52.962 INFO  (qtp475266352-20) [   ] o.a.s.s.HttpSolrCall [admin] webapp=null path=/admin/info/system params={wt=json&_=1497969532684} status=0 QTime=76

1 个答案:

答案 0 :(得分:0)

您提到的错误是由丢失的文件引起的: 段*例如segments_3 ...... 在索引文件中: 文件:[_ fh2.fdt,_fh2.fdx,_fh2.fnm,_fh2.nvd,_fh2.nvm,_fh2.si,_fh2_Lucene50_0.doc,_fh2_Lucene50_0.pos,_fh2_Lucene50_0.tim,_fh2_Lucene50_0.tip,write.lock]

该文件指定要考虑的最后一个提交点和最后一代段,显然它是缺失的。 检查该文件是否存在且可读。

如果不是(因为例如索引编写器由于被删除而未正确关闭,请不要绝望。

有可能事务日志仍包含您编制索引的文档,因此您可以重放它并获取文档(清理索引目录,使solr启动并且应该注意)。 Solr还允许备份功能,因此将来您可能需要对其进行配置。