提问者:小点点

打开lucene索引时出错:java.io.io异常:映射失败


我有一个问题,我认为与这里描述的问题相同:

打开lucene索引时出错:映射失败

然而,解决方案不适用于这种情况,因此我将提供更多细节并再次询问。

索引是使用 Solr 5.3 创建的

导致异常的代码行是:

IndexReader indexReader = DirectoryReader.open(FSDirectory.open(Paths.get("the_path")));

异常堆栈跟踪为:

Exception in thread "main" java.io.IOException: Map failed: MMapIndexInput(path="/mnt/fastdata/ac1zz/JATE/solr-5.3.0/server/solr/jate/data_aclrd/index/_5t.tvd") [this may be caused by lack of enough unfragmented virtual address space or too restrictive virtual memory limits enforced by the operating system, preventing us to map a chunk of 434505698 bytes. Please review 'ulimit -v', 'ulimit -m' (both should return 'unlimited'), and 'sysctl vm.max_map_count'. More information: http://blog.thetaphi.de/2012/07/use-lucenes-mmapdirectory-on-64bit.html]
at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:907)
at org.apache.lucene.store.MMapDirectory.map(MMapDirectory.java:265)
at org.apache.lucene.store.MMapDirectory.openInput(MMapDirectory.java:239)
at org.apache.lucene.codecs.compressing.CompressingTermVectorsReader.<init>(CompressingTermVectorsReader.java:144)
at org.apache.lucene.codecs.compressing.CompressingTermVectorsFormat.vectorsReader(CompressingTermVectorsFormat.java:91)
at org.apache.lucene.index.SegmentCoreReaders.<init>(SegmentCoreReaders.java:120)
at org.apache.lucene.index.SegmentReader.<init>(SegmentReader.java:65)
at org.apache.lucene.index.StandardDirectoryReader$1.doBody(StandardDirectoryReader.java:58)
at org.apache.lucene.index.StandardDirectoryReader$1.doBody(StandardDirectoryReader.java:50)
at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:731)
at org.apache.lucene.index.StandardDirectoryReader.open(StandardDirectoryReader.java:50)
at org.apache.lucene.index.DirectoryReader.open(DirectoryReader.java:63)
at uk.ac.shef.dcs.jate.app.AppATTF.extract(AppATTF.java:39)
at uk.ac.shef.dcs.jate.app.AppATTF.main(AppATTF.java:33)

异常消息中建议的解决方案在这种情况下不起作用,因为我在服务器上运行应用程序,而我没有权限更改这些。

ulimit -v unlimited

打印:"-bash: ulimit:虚拟内存:无法修改限制:不允许操作"

和sysctl-wvm.max_mp_count=10000000

给出:"错误:拒绝对密钥'vm.max_map_count'的权限"

无论如何,我能解决这个问题吗?

谢谢


共1个答案

匿名用户

我找到了解决办法,所以我自己回答。

如果你真的不能设置ulimit或vm.max_map_count,根据 http://blog.thetaphi.de/2012/07/use-lucenes-mmapdirectory-on-64bit.html,唯一的解决方案是配置你的solr(或者如果你使用Lucene api,明确选择)使用SimpleFSDirectory(如果是windows)或NIOFSDirectory,两者都比默认值慢。

怎么说?

DirectoryReader.open(new NIOFSDirectory(Paths.get("path_to_index"), FSLockFactory.getDefault()))