您的位置:首页 > 其它

实战: SOLR的分布式部署(复制)CollectionDistribute 快照分发 (精简版)

2010-03-19 23:58 435 查看
SOLR复制模式,是一种在分布式环境下用于同步主从服务器的一种实现方式,因之前提到的基于rsync的SOLR不同方式部署成本过高,被SOLR1.4版本所替换,取而代之的就是基于HTTP协议的索引文件传输机制,该方式部署简单,只需配置一个文件即可。 以下讲解具体操作步骤:

步骤分主服务器和从服务器,允许有多个从服务器,即从服务器的配置一样。

主服务器:

在solrConfig.xml中,找到以下行:

<requestHandler name="/replication" class="solr.ReplicationHandler" >

view plaincopy to clipboardprint?<requestHandler name="/replication" class="solr.ReplicationHandler" >
<lst name="master">
<str name="replicateAfter">commit</str>

<str name="confFiles">schema.xml,stopwords.txt,elevate.xml</str>

<str name="commitReserveDuration">00:05:00</str>
<str name="httpBasicAuthUser">123</str>
<str name="httpBasicAuthPassword">123</str>

</lst>
</requestHandler>
说明:

replicateAfter : SOLR会自行在以下操作行为发生后执行复制: 'commit', 'startup' 'optimize',这里我们选择commit , 即SOLR每一次接受到commit请求后,会执行复制策略。
confFiles : 待分发的配置文件,solr 也会将主服务器上的字段配置文件:schema.xml和stopwords.txt,固排文件: elevate.xml同步到辅服务器上。
commitReserveDuration: 每次commit之后,保留增量索引的周期时间,这里设置为5分钟。
从服务器

view plaincopy to clipboardprint?<requestHandler name="/replication" class="solr.ReplicationHandler" >
<lst name="slave">

<str name="masterUrl">http://localhost:port/solr/corename/replication</str>

<str name="pollInterval">00:05:00</str>

<str name="compression">internal</str>

<str name="httpConnTimeout">5000</str>
<str name="httpReadTimeout">10000</str>

<str name="httpBasicAuthUser">123</str>
<str name="httpBasicAuthPassword">123</str>

</lst>
</requestHandler>
<requestHandler name="/replication" class="solr.ReplicationHandler" >     <lst name="slave">          <str name="masterUrl">http://localhost:port/solr/corename/replication</str>            <str name="pollInterval">00:05:00</str>                    <str name="compression">internal</str>                 <str name="httpConnTimeout">5000</str>         <str name="httpReadTimeout">10000</str>           <str name="httpBasicAuthUser">123</str>         <str name="httpBasicAuthPassword">123</str>       </lst> </requestHandler>
说明:

masterUrl : 主服务器同步URL地址
pollInterval:从服务器同步间隔,即每隔多长时间同步一次主服务器
httpConnTimeout:设置连接超时(单位:毫秒)
httpReadTimeout:如果设置同步索引文件过大,则应适当提高此值。(单位:毫秒)
httpBasicAuthUser:验证用户名,需要和主服务器一致
httpBasicAuthPassword:验证密码,需和主服务器一致
compression:external or internal 使用SOLR自己的压缩算法或应用容器的
区别: 内部算法会大大提高同步成本,原话: USE THIS ONLY IF YOUR BANDWIDTH IS LOW . THIS CAN ACTUALLY SLOWDOWN REPLICATION IN A LAN。

因此建议使用外部方式即: external .

同时需要配置外部应用容器: 以TOMCAT为例:

view plaincopy to clipboardprint?<Connector compression="on"
compressableMimeType="text/html,text/xml,text/plain"
compressionMinSize="2048"/>
<Connector compression="on" compressableMimeType="text/html,text/xml,text/plain" compressionMinSize="2048"/>

最后保存,重启SOLR即可。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: