0
这基本上是一样的这个问题,但没有有用的答案,情况略有不同:SOLR占用内存过多(部分2)
我们正在运行SOLR 5.5。 0在JDK版本1.8.0_77-b03的Windows 2008 R2上。在运行我们的索引过程时,运行SOLR的java进程具有一个私有工作集,最终使用该框中的所有8 GB内存。
我们使用我们使用SOLRJ客户端编写的Spring Batch Starter流程为3M +文档建立索引。这是一个索引文件,我们已经收集到的代码:
log.info("Adding " + docList.size() + " documents to Solr index");
if(docList.size() == 0) {
log.warn("Was asked to index 0 records, but input size was " + items.size());
} else {
log.debug("Splitting list of size " + docList.size() + " into manageable chunks of " + batchCommitSize);
List<List<SolrInputDocument>> partitionedList = Lists.partition(docList, batchCommitSize);
SolrClient solrClient = (SolrClient) applicationContext.getBean("solrClient");
for (List<SolrInputDocument> chewableChunk : partitionedList) {
solrClient.add(chewableChunk);
solrClient.commit();
log.info(chewableChunk.size() + " documents committed.");
}
log.info("Finished batch indexing of " + docList.size() + " documents.");
}
为SOLRJ客户的Spring配置:
@Value("${code.search.num.solr.threads}")
private int numSolrThreads;
@Bean(destroyMethod = "close")
public ConcurrentUpdateSolrClient solrClient() {
return new ConcurrentUpdateSolrClient(solrHost, 100, numSolrThreads);
}
//code.search.num.solr.threads=25
这是我们的模式定义。它真的很长,所以我只是剪切和粘贴部分与我们的字段定义。如有必要,我可以上传更多内容它大部分是从教程中的示例配置中复制的。
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="_version_" type="long" indexed="true" stored="true"/>
<field name="_root_" type="string" indexed="true" stored="false"/>
<field name="_text_" type="text_general" indexed="true" stored="false" multiValued="true"/>
<copyField source="*" dest="_text_"/>
<field name="fileName" type="string" indexed="true" stored="true" required="true"/>
<field name="projectName" type="string" indexed="true" stored="true" required="true"/>
<field name="lastCommitAuthor" type="string" indexed="true" stored="true"/>
<field name="vcsUrl" type="string" indexed="true" stored="true"/>
<field name="teamCityUrl" type="string" indexed="true" stored="true"/>
<field name="jenkinsUrl" type="string" indexed="true" stored="true"/>
<field name="content" type="text_general" indexed="true" stored="true" required="true"/>
<field name="relativePath" type="string" indexed="true" stored="true" required="true"/>
<!-- Field to use to determine and enforce document uniqueness.
Unless this field is marked with required="false", it will be a required field
-->
<uniqueKey>id</uniqueKey>
上一个问题表明内存映射文件可能是罪魁祸首,但我们一直无法找到一种方法来解决这个问题。我们也尝试在每次提交时关闭并重新创建客户端,
有什么办法可以减少索引时SOLR使用的内存量?
你为你的Solr进程分配了多少内存? –
4GB。内存选项为-XX:+ UseG1GC^ -XX:SurvivorRatio = 4^ -XX:+ UseStringDeduplication -XX:+ AggressiveHeap' – Brad