六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 546|回复: 0

Solr主从集群配置简要说明

[复制链接]
 楼主| 发表于 2016-3-3 12:04:28 | 显示全部楼层 |阅读模式
Solr主从集群配置简要说明
关于solr的集群主要分为主从和SolrCloud两种。主从,比较适合以读为主的场景。SolrCloud适合数据量大,时不时会有更新的情形。那么solr的主从配置很简单。在solrconfig.xml中找到 <requestHandler name="/replication" class="solr.ReplicationHandler" > 。这里的replication主要解决主从复制的。它主要实现:在主进行数据写操作,在slave节点进行读操作。当并发量大些,可以通过扩展slave节点数来应对,多个slave做一个反向代理和负载均衡(在本文中,就不做说明了,如有需要,可以使用nginx或者apache等负载软件),供查询使用。好了,先看看主节点配置:
  1. <requestHandler name="/replication" class="solr.ReplicationHandler" >
  2.   <!--
  3.      To enable simple master/slave replication, uncomment one of the
  4.      sections below, depending on whether this solr instance should be
  5.      the "master" or a "slave".  If this instance is a "slave" you will
  6.      also need to fill in the masterUrl to point to a real machine.
  7.   -->

  8.      <lst name="master">
  9.        <str name="replicateAfter">commit</str>
  10.        <str name="replicateAfter">startup</str>
  11.        <str name="confFiles">schema.xml,stopwords.txt,spellings.txt,synonyms.txt</str>
  12.      </lst>

  13.   <!--
  14.      <lst name="slave">
  15.        <str name="masterUrl">http://your-master-hostname:8983/solr</str>
  16.        <str name="pollInterval">00:00:60</str>
  17.      </lst>
  18.   -->
复制代码
master 标志该core 为主节点。复制的行为发生在commit、startup之后。cofFiles表示,向从节点复制的配置文件(记住,主从的solrconfig.xml配置不一样,不要把solrconfig.xml也复制到从节点了)。<br><br>  再看看slave节点的配置,slave配置很简单,把上面的配置文件中master那段注释掉。把slave那段放开即可。将masterUrl换成master的url,格式:http://your-master-host:port/solr/your_core_name。具体配置如下:
  1. <requestHandler name="/replication" class="solr.ReplicationHandler" >
  2.     <!--
  3.        To enable simple master/slave replication, uncomment one of the
  4.        sections below, depending on whether this solr instance should be
  5.        the "master" or a "slave".  If this instance is a "slave" you will
  6.        also need to fill in the masterUrl to point to a real machine.
  7.     -->
  8.     <!--
  9.        <lst name="master">
  10.          <str name="replicateAfter">commit</str>
  11.          <str name="replicateAfter">startup</str>
  12.          <str name="confFiles">schema.xml,stopwords.txt</str>
  13.        </lst>
  14.     -->
  15.    
  16.        <lst name="slave">
  17.          <str name="masterUrl">http://192.9.104.116:8090/solr/POI</str>
  18.          <str name="pollInterval">00:00:20</str>
  19.        </lst>
  20.    
  21.   </requestHandler>
复制代码
pollInterval 表示多久向master同步一次数据,数据格式{时}:{分}:{秒}。这个要根据你的业务场景。如果更新比较频繁,就把这个值调小点,反之,就调大些。在同步数据时,根据网络和机器配置等不同,slave之间的数据会存在不同步的情况。如果,你对此有要求,需要注意了。总之,任何一种集群方案都不是万能的。solr的主从模式目前存在诸多问题,比如:主节点有单点故障等等,希望后续的版本会有些改进。


http://www.cnblogs.com/likehua/p/4353354.html

Solr主从集群配置简要说明

该会员没有填写今日想说内容.
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表