我正在尝试将整个 Solr 实例加载到内存中,我有 6000 万条包含 10 个字段的记录,(6 个字段已编入索引,其中 icnlude DateTime
、c_Text
和 string
)。我在磁盘上的总 solr 实例大小为 15 GB,我已将 JVM 内存设置为:
Initial Memory Pool: 2048 (2 GB)
Maximum Memory Pool: 20480 (20 GB)
我将 solrconfig.xml
中的缓存配置更改为:
<documentCache class="solr.LRUCache"
size="6000000"
initialSize="2000000"
autowarmCount="0"/>
但对于每次搜索,它仍然从磁盘读取(通过 Windows 上的 PerfMon 实用程序检查)。同样在任务管理器中,它显示 tomcat
占用了 500 MB 的 RAM。我看过这个问题:Solr loads entire index into memory但它没有一个可接受的答案,我也尝试根据该问题增加缓存大小,但它仍然不会增加 tomcat
的内存使用量。
我正在使用 Solr 4.4 和 Tomcat 7.0.42
最佳答案
您可以使用 RAMDirectory
将整个索引构建到 RAM 中。
这可以在您的 solrconfig.xml 中完成
<config>
<!-- ... -->
<directoryFactory name="DirectoryFactory"
class="org.apache.solr.core.RAMDirectoryFactory"/>
<!-- ... -->
</config>
然而,对于现场的一切,这有利也有弊。可以在 SO 问题 Need to know pros and cons of using RAMDirectory 中阅读很好的阐述.
然后您应该考虑减小缓存的大小。
关于windows - 在内存中加载整个 Solr 实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20053120/