利用 Replication Handler 备份索引

solr 索引备份最简单的方式是通过 Replication Handler。在使用 Replication Handler 之前,需要将 solrconfig.xml 中 SolrReplicationHandler 的注释去掉:

     <requestHandler name="/replication" class="solr.ReplicationHandler" >
       <lst name="master">
         <str name="replicateAfter">commit</str>
         <str name="replicateAfter">startup</str>
         <str name="confFiles">schema.xml,stopwords.txt</str>
       </lst>
       <lst name="slave">
         <str name="masterUrl">http://localhost:8983/solr/replication</str>
         <str name="pollInterval">00:00:60</str>
       </lst>
     </requestHandler>
然后启动 web 容器,启动完成后执行

http://localhost:81/apache-solr-3.5.0/replication?command=backup

该请求成功的话,会得到:

<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">42</int>
</lst>
<str name="status">OK</str>
</response>

此时在 solr/home 的 data 目录下,会发现类似 snapshot.20120626210126 的目录,该目录就是备份出来的索引库

Copyright © All Rights Reserved · Green Hope Theme by Sivan & schiy · Proudly powered by WordPress · 闽ICP备18020075号