如何通过 SolrJ 客户端执行远程 Solr 核心备份? [英] How to perform a remote Solr core backup through SolrJ client?

查看:27
本文介绍了如何通过 SolrJ 客户端执行远程 Solr 核心备份?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个基于 SolrJ 的 Java 客户端,它将整个核心数据从远程 Solr 服务器拉到一个文件中.稍后我想将此文件重播到另一个远程 Solr 服务器核心.

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?

推荐答案

现在可以使用最新的 Solr 版本.

It's now possible with latest Solr versions.

要在一台 Solr Server 上实现备份并在另一台 Solr Server 上恢复需要执行以下操作:

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

  1. 对于 solr.xml 设置备份存储库中的每个 Solr 安装,以指向某个共享驱动器.例如,可以使用 HDFS(此配置需要将 -Dsolr.hdfs.home=... 添加到启动脚本中):
  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. 从一台服务器创建备份:

SolrClient client1 = ...;
CollectionAdminRequest.Backup request1 = new CollectionAdminRequest.Backup(oldCollectionName, backupName);
request1.setRepositoryName("hdfs-repo");
request1.process(client1);

  1. 然后从另一台服务器上的备份恢复:

SolrClient client2 = ...;
CollectionAdminRequest.Restore request2 = new CollectionAdminRequest.Restore(newCollectionName, backupName);
request2.setRepositoryName("hdfs-repo");
request2.process(client2);

此示例适用于 Solr 7.5,但看起来该功能在 6.6 中已经存在(参见 6.6 中的备份/恢复).

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

这篇关于如何通过 SolrJ 客户端执行远程 Solr 核心备份?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆