如何备份&恢复ElasticSearch

时间:2017-02-09 07:00:03

标签: elasticsearch

我一直在尝试以下方法来备份&将ElasticSearch集群从一台服务器还原到另一台服务器,但收效甚微。到目前为止我还没有使用备份过程,我想将整个ElasticSearch集群从一个小的2GB集群移动到15GB集群。我使用了以下方法。

  1. 使用taskrabit/elasticsearch-dump - 我已成功将整个数据库导出到backup.json文件,但是在恢复backup.json时,它给了我以下输出。在进一步研究输出之后,我了解到插件的批量输入尚未完全开发。

    ./bin/elasticdump --all=true --input=/home/user/backup.json --output=http://192.168.0.213:9200/ --type=data
    Thu, 09 Feb 2017 06:43:29 GMT | starting dump
    Thu, 09 Feb 2017 06:43:29 GMT | got 61 objects from source file (offset: 0)
    Thu, 09 Feb 2017 06:43:29 GMT | sent 61 objects to destination elasticsearch, wrote 0
    Thu, 09 Feb 2017 06:43:29 GMT | got 0 objects from source file (offset: 61)
    Thu, 09 Feb 2017 06:43:29 GMT | Total Writes: 0
    Thu, 09 Feb 2017 06:43:29 GMT | dump complete
    
  2. 使用elasticsearch-tools(es-export-bulk& es-import bulk)我再次成功备份了json。但导入再次失败并出现错误:

    "statusCode":400,"response":"{"error":{ 
    
  3. 我使用了es-bulk-export

    中的示例
    1. 使用内置快照的ElasticSearch&恢复..

      curl -XPUT 'http://localhost:9200/_snapshot/my_backup' -d '{
        "type": "fs",
         "settings": {"location": "/home/shawn/backup", "compress": true}
      }'
      
    2. 我相信我遗漏了一些东西,因为执行会给我以下错误。我需要创建/_snapshot/my_backup吗?如果是这样的话?

      {"error":{"root_cause":[
        {"type":"repository_exception",
         "reason":"[my_backup] location [/home/shawn/backup] doesn't match any of the locations specified by path.repo because this setting is empty"
        }],
         "type":"repository_exception","reason":"[my_backup] failed to create repository",
         "caused_by":
             {"type":"creation_exception","reason":"Guice creation errors:\n\n1) Error injecting constructor, RepositoryException[[my_backup] location [/home/shawn/backup] doesn't match any of the locations specified by path.repo because this setting is empty]\n  at org.elasticsearch.repositories.fs.FsRepository.<init>(Unknown Source)\n  while locating org.elasticsearch.repositories.fs.FsRepository\n  while locating org.elasticsearch.repositories.Repository\n\n1 error","caused_by":{"type":"repository_exception","reason":"[my_backup] location [/home/shawn/backup] doesn't match any of the locations specified by path.repo because this setting is empty"}}},"status":500}
      

2 个答案:

答案 0 :(得分:0)

您正在创建_snapshot / my_backup,您只需要在 /etc/elasticsearch/elasticsearch.yml 中添加一行:

path.repo: ["/home/shawn/backup"]

快照的实际位置。然后重新启动Elasticsearch。

答案 1 :(得分:0)

尝试以下步骤。

  1. 复制位于源elasticsearch文件夹内的数据文件夹。将其粘贴到新的目标Elasticsearch文件夹中。

  2. 在该数据文件夹内,您将找到一个带有群集名称的文件夹。假设

  

apoorv-es-app

enter image description here

  1. 此集群的名称应与elasticsearch.yml文件中提到的集群名称匹配。

enter image description here

  1. 在elasticsearch.yml中提及此文件夹的路径,如下所示。

enter image description here

之后,您最好启动Elasticsearch应用。

  

./ bin / elasticsearch