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

打开lucene索引时出错:java.io.IOException:映射失败,java,solr,lucene,Java,Solr,Lucene,我有一个问题,我认为与这里描述的问题相同: 但是,该解决方案不适用于这种情况,因此我将提供更多细节并再次询问 索引是使用Solr 5.3创建的 导致异常的代码行是: IndexReader indexReader = DirectoryReader.open(FSDirectory.open(Paths.get("the_path"))); 异常stacktrace是: Exception in thread "main" java.io.IOException: Map failed: M

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

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

索引是使用Solr 5.3创建的

导致异常的代码行是:

IndexReader indexReader = DirectoryReader.open(FSDirectory.open(Paths.get("the_path")));
异常stacktrace是:

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)
打印:“-bash:ulimit:虚拟内存:无法修改限制:不允许操作”

及 sysctl-w vm.max\u map\u count=10000000

给出:“错误:对键“vm.max\u map\u count”的权限被拒绝”

我能解决这个问题吗


谢谢

我找到了一个解决方案,所以我自己回答

如果您确实无法设置ulimit或vm.max_map_count,根据,唯一的解决方案是将solr(或者如果您使用Lucene api,请显式选择)配置为使用SimpleFSDirectory(如果是windows)或NIOFSDirectory,两者都比默认值慢

比如说

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

听起来你应该问的是:
DirectoryReader.open(new NIOFSDirectory(Paths.get("path_to_index"), FSLockFactory.getDefault()))