solr 索引备份最简单的方式是通过 Replication Handler。在使用 Replication Handler 之前,需要将 solrconfig.xml 中 SolrReplicationHandler 的注释去掉:
1 2 3 4 5 6 7 8 9 10 11 | < 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" ></ str > < str name = "pollInterval" >00:00:60</ str > </ lst > </ requestHandler > |
然后启动 web 容器,启动完成后执行
http://localhost:81/apache-solr-3.5.0/replication?command=backup
该请求成功的话,会得到:
1 2 3 4 5 6 7 | < 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 的目录,该目录就是备份出来的索引库