西湖鱼 发表于 2017-12-18 21:31:33

solr clould 主从同步

solr/replication的描述  

  
在分布式solrcloud的大热之下,solr的主从同步机制似乎被遗忘。其实对于大多数的搜索服务或者数据服务的数量级来说,根本用不上solrcloud,而且solrcloud未必能带来性能的提升。而主从同步机制,配置简单,使用灵活,对环境要求低,往往适用的场景更多。
  

  
典型的主从复制模式(master/slave)的配置方案
  

  
solrconfig.xml的配置
  
master:
  

  

<requestHandler name="/replication">  
<lst name="master">
  
<str name="replicateAfter">optimize</str>
  
<str name="backupAfter">optimize</str>
  
<str name="confFiles">schema.xml,stopwords.txt,elevate.xml</str>
  
<str name="commitReserveDuration">00:00:10</str>
  
</lst>
  
<int name="maxNumberOfBackups">2</int>
  
<lst name="invariants">
  
<str name="maxWriteMBPerSec">16</str>
  
</lst>
  
</requestHandler>
  

  
maxNumberOfBackups:最大备份数量
  
confFiles:主从进行同步的文件
  
commitReserveDuration:网络很慢的情况下,每次commit之后,保留增量索引的周期时间,默认是10秒
  

  
slave:
  
<requestHandler name="/replication">
  
<lst name="slave">
  
<str name="masterUrl">http://remote_host:port/solr/core_name/replication</str>
  
<str name="pollInterval">00:00:20</str>
  
<str name="compression">internal</str>
  
<str name="httpConnTimeout">5000</str>
  
<str name="httpReadTimeout">10000</str>
  
<str name="httpBasicAuthUser">username</str>
  
<str name="httpBasicAuthPassword">password</str>
  
</lst>
  
</requestHandler>
  

  

  
- masterUrl:master主机的solr地址,eg: http://192.168.11.13:8280/solr/androidapp
  
- pollInterval:轮询的间隔时间
  

  
操作solr/replication的API
  

  
使master的主从服务生效:
  
http://master_host:port/solr/core_name/replication?command=enablereplication
  

  
使master的主从服务失效:
  
http://master_host:port/solr/core_name/replication?command=disablereplication
  

  
查看当前索引的版本:
  
http://host:port/solr/core_name/replication?command=indexversion
  

  
手动从master拉取数据到slave:
  
http://slave_host:port/solr/core_name/replication?command=fetchindex
  

  
使slave的轮询失效:
  
ttp://slave_host:port/solr/core_name/replication?command=disablepoll
  

  
使slave的轮询生效:
  
http://slave_host:port/solr/core_name/replication?command=enablepoll
  

  
执行备份:
  
http://master_host:port/solr/core_name/replication?command=backup
  

  
删除备份:
  
http://master_host:port /solr/core_name/replication?command=deletebackup
页: [1]
查看完整版本: solr clould 主从同步