如何使用多核配置 Solr 复制 [英] How do I configure Solr replication with multiple cores

查看:51
本文介绍了如何使用多核配置 Solr 复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个内核运行的 Solr.因为负载很重,我想设置一个包含完全相同索引的slave.

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

文档 http://wiki.apache.org/solr/SolrReplication 指出将复制请求处理程序添加到每个核心的 solrconfig.xml",但我只有一个 solrconfig.xml.

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.

我的配置:
配置:/data/solr/web/solr/conf/config 文件
数据:/data/solr/data/solr/core 数据目录

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

真的有必要为每个核心复制solrconfig.xml吗?
我应该把这些多个 solrconfig 文件放在哪里?

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>

推荐答案

您需要做的是复制您在从服务器上的 solr 实例,并在 solrconfig.xml.最佳做法是为每个内核设置不同的 instanceDir 目录,因为通常每个内核都有自己的 schema.xmlsolrconfig.xml.无论如何,您可以使用相同的 conf 配置您的 solr.xml 以指向相同的 instanceDir 但不同的 dataDir,您将其配置为 dataDir 在你的 solrconfig.xml 中:

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>

如果您当前有多个内核但只有一个 solrconfig.xml,这应该是您的情况.

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

slaves上的solrconfig.xml复制部分需要包含master的url,包括核心名称,当然每个核心都不一样.但是您可以像这样使用占位符 ${solr.core.name}:

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>

事实上,像solr.core.name这样的一些属性会自动添加到核心作用域 并且您可以在您的配置中引用它们.因此,如果您没有任何特定于内核的设置,则每个内核的复制部分都可以相同.

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.

此外,您可以对 master 和 slave 使用相同的配置以下配置,并根据您想要执行的操作更改您分配给环境变量 enable.masterenable.slave 的值(true 或 false).我的意思是你可以使用相同的文件,但当然它会在不同的机器上,因为在同一台机器上拥有主站和从站没有多大意义.

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>

这篇关于如何使用多核配置 Solr 复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆