公司的架构没有zookeeper,所以solr还是用原有的Replication方式进行负载。
在Solr example里面的core/conf/solrconfig.xml下面,有一段Replication的配置:
<!-- Solr Replication
The SolrReplicationHandler supports replicating indexes from a
"master" used for indexing and "slaves" used for queries.
http://wiki.apache.org/solr/SolrReplication
It is also necessary for SolrCloud to function (in Cloud mode, the
replication handler is used to bulk transfer segments when nodes
are added or need to recover).
https://wiki.apache.org/solr/SolrCloud/
-->
<requestHandler name="/replication" class="solr.ReplicationHandler" >
<!--
To enable simple master/slave replication, uncomment one of the
sections below, depending on whether this solr instance should be
the "master" or a "slave". If this instance is a "slave" you will
also need to fill in the masterUrl to point to a real machine.
-->
<lst name="master">
<str name="replicateAfter">commit</str>
<str name="replicateAfter">startup</str>
<str name="replicateAfter">optimize</str>
<!-- 需要同步到slave的配置文件,用逗号分隔 -->
<str name="confFiles">schema.xml</str>
<str name="commitReserveDuration">00:00:20</str>
</lst>
<!--
<lst name="slave">
<!--master地址,solr/core_name-->
<str name="masterUrl">http://127.0.0.1:8081/solr/collection_8081</str>
<str name="httpConnTimeout">5000</str>
<str name="httpReadTimeout">10000</str>
<str name="pollInterval">00:00:60</str>
</lst>
-->
</requestHandler>
Master就按照主节点的配置进行设置。
Slave就按照备节点的配置进行设置。
说明:
1)replicateAfter可取startup、commit、optimize,表示触发复制的时机。使用中,这三个值都可以配上。
2)backupAfter表示备份时机,如果需要备份,solr会在配置的时机自动生成备份。
3)confFiles表示在复制时需要复制到slave的文件列表。我们的环境只需要schema.xml
4)commitReserveDuration默认是10秒,这个值通常你通常不需要修改,除非你的网络慢到传输5M数据需要10秒以上的时间。
命令格式:http://[host]:[port]/solr/[core]/replication?command=[command name]
关于 Replication的一些 HTTP API
solr的ReplicationHandler提供了一系列http命令(参数command),支持的可选值如下:
1)indexversion:slave从master获取最新的索引点信息。
2)filecontent:slave从master下载指定文件的内容。
3)filelist:slave从master获取指定indexversion的索引文件列表(及需要复制的配置文件)。
4)backup:备份索引。如果担心索引有损坏的可能性,可以定期备份索引。
5)fetchindex:手动复制数据,和slave自动复制相当。
6)disablepoll:停止slave的复制。
7)enablepoll:开启slave的复制。
8)abortfetch:终止slave上正在进行的下载文件过程。
9)commits:show当前仍旧保留的IndexCommit信息。
10)details:show slave当前的复制细节信息。
11)enablereplication:启动master对所有slave的复制功能
12)disablereplication:关闭master对所有slave的复制功能
配置好的master:

配置好的slave:


710

被折叠的 条评论
为什么被折叠?



