How do I configure Solr replication with multiple cores

此生再无相见时 提交于 2019-12-20 09:44:48

问题


I have Solr running with multiple cores. Because of the heavy load, I want to set up a slave containing the exact same indexes.

The documentation http://wiki.apache.org/solr/SolrReplication states "Add the replication request handler to solrconfig.xml for each core", but I only have one solrconfig.xml.

My configuration:
Config: /data/solr/web/solr/conf/config files
Data: /data/solr/data/solr/core data dirs

Is it really necessary to copy the solrconfig.xml for each core?
And where should I put these multiple solrconfig files?

solr.xml

<?xml version="1.0" encoding="UTF-8" ?>
  <solr persistent="true">
  <property name="dih.username" value="user"/>
  <property name="dih.password" value="passwd"/>
  <property name="jdbclib" value="/usr/progress/dlc102b/java"/>
  <property name="dih.dburl" value="jdbc:datadirect:openedge://172.20.7.218:31380;databaseName=easource"/> <cores adminPath="/admin/cores">
    <core instanceDir="/data/solr/web/trunk/" name="product" dataDir="/data/solr/data/trunk/product-swap">
      <property name="dih-config" value="dih-config-product.xml"/>
    </core>
    <core instanceDir="/data/solr/web/trunk/" name="product-swap" dataDir="/data/solr/data/trunk/product">
      <property name="dih-config" value="dih-config-product.xml"/>
    </core>
    <core instanceDir="/data/solr/web/trunk/" name="periodp" dataDir="/data/solr/data/trunk/periodp">
      <property name="dih.config" value="dih-config-periodp.xml"/>
    </core>
    <core instanceDir="/data/solr/web/trunk/" name="periodp-swap" dataDir="/data/solr/data/trunk/periodp-swap">
      <property name="dih.config" value="dih-config-periodp.xml"/>
    </core>
  </cores>
</solr>

回答1:


What you need to do is copy the solr instance that you have on the slave server and configure the replication handler on the solrconfig.xml. It's best practice to have a different instanceDir directory for each core since usually every core has its own schema.xml and solrconfig.xml. Anyway you can use the same conf just configuring your solr.xml to point to the same instanceDir but a different dataDir, which you configure as dataDir in your solrconfig.xml as well:

<solr persistent="true" sharedLib="lib">
    <cores adminPath="/admin/cores">
        <core name="core0" instanceDir="core">
            <property name="dataDir" value="/data/core0" />
        </core>
        <core name="core1" instanceDir="core">
            <property name="dataDir" value="/data/core1" />
        </core>
    </cores>
</solr>

This should be your situation if you currently have multiple cores but a single solrconfig.xml.

The solrconfig.xml replication section on the slaves need to contain the url of the master, including the core name, which of course is different for each core. But you can use the placeholder ${solr.core.name} like this:

<requestHandler name="/replication" class="solr.ReplicationHandler" >
    <lst name="slave">
        <str name="masterUrl">http://master_host:port/solr/${solr.core.name}/replication</str>
        <str name="pollInterval">00:00:20</str>
    </lst>
</requestHandler>

In fact, some properties like solr.core.name are automatically added to the core scope and you can refer to them in your configuration. As a result, the replication section can be the same for every core if you don't have any core specific settings.

Furthermore, you could use the same config for master and slave with the following configuration and just change the value (true or false) that you assign to the environment variables enable.master and enable.slave based on what you want to do. I mean that you can use the same file, but of course it's going to be on different machines since it wouldn't make a lot of sense to have master and slaves on the same machine.

<requestHandler name="/replication" class="solr.ReplicationHandler" >
    <lst name="master">
        <str name="enable">${enable.master:false}</str>
        <str name="replicateAfter">commit</str>
    </lst>
    <lst name="slave">
        <str name="enable">${enable.slave:false}</str>
        <str name="masterUrl">http://master_host:8983/solr/${solr.core.name}/replication</str>
        <str name="pollInterval">00:00:60</str>
    </lst>
</requestHandler>



回答2:


Yes, you need to have the exact same copy of the files in each copy of the core you're replicating.

To unload even more your solr instances, i suggest you to have a master used only for indexing and 2 slaves, replicated from master, used to query your documents.



来源:https://stackoverflow.com/questions/13065341/how-do-i-configure-solr-replication-with-multiple-cores

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!