How to perform a remote Solr core backup through SolrJ client?

雨燕双飞 提交于 2019-11-28 05:33:26

问题


I want to write a java client based on SolrJ which pulls the entire core data to a file from a remote Solr server. Later on I want to replay this file to another remote Solr server core.

What is the best method to implement this functionality?


回答1:


It's now possible with latest Solr versions.

To achieve backup on one Solr Server and restore on another one needs to do the following:

  1. For each Solr installation in solr.xml setup backup repository to point to some shared drive. For example, one can use HDFS (this config requires -Dsolr.hdfs.home=... to be added into start script):
<solr>
...
<backup>
    <repository name="hdfs-repo" class="org.apache.solr.core.backup.repository.HdfsBackupRepository" default="false">
      <str name="location">${solr.hdfs.home}/backup</str>
      <str name="solr.hdfs.home">${solr.hdfs.home:}</str>
      <str name="solr.hdfs.confdir">${solr.hdfs.confdir:}</str>
    </repository>
</backup>
</solr>
  1. Create backup from one server:
SolrClient client1 = ...;
CollectionAdminRequest.Backup request1 = new CollectionAdminRequest.Backup(oldCollectionName, backupName);
request1.setRepositoryName("hdfs-repo");
request1.process(client1);
  1. Then restore from backup on another server:
SolrClient client2 = ...;
CollectionAdminRequest.Restore request2 = new CollectionAdminRequest.Restore(newCollectionName, backupName);
request2.setRepositoryName("hdfs-repo");
request2.process(client2);

This example works with Solr 7.5, but looks like the feature was already there in 6.6 (See Backup/Restore in 6.6).




回答2:


Unfortunately, there is no such functionality in solr nor in solrj.

But if you have all fields stored in your index, you just could read out all documents and store them the way you want.




回答3:


Check if it applies to your case:

Backup - You can perform a backup, however the backup will be created on the Server only.

Create a backup on master if there are committed index data in the server, otherwise do nothing. This is useful to take periodic backups.

You can use Solr replication to replicate the Content of the Index to any Remote Solr server.

So you can either replicate your index to a local box and then replicate it again to a remote box OR backup and just transfer the contents to a remote box.



来源:https://stackoverflow.com/questions/13947621/how-to-perform-a-remote-solr-core-backup-through-solrj-client

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!