Elastichsearch数据备份,恢复,及迁移

目的:将数据从A集群迁移到B集群,大概步骤:创建快照->导出->迁移备份->导入

1、vi /etc/elasticsearch/elasticseach.yml, 添加path.repo: /path/to/backup,重启A集群的Elasticseach. B集群也要执行此步骤,且所有的节点都需要。

2、创建快照(B集群也需要)

curl -XPUT  http://127.0.0.1:9500/_snapshot/my_backup -d '
{
    "type": "fs",
    "settings": {
        "location": "/path/to/backup",
        "compress" : true
    }
}
'

curl -XGET http://127.0.0.1:9500/_snapshot/my_backup //检查快照信息

3、导出备份文件

curl -XPUT '127.0.0.1:9500/_snapshot/my_backup/snapshot_20170116?pretty' -d'
{
  "indices": "poi.v1,poi.v2", //要到处的索引
  "ignore_unavailable": true,
  "include_global_state": false
}
'

curl -XGET http://127.0.0.1:9500/_snapshot/my_backup/snapshot_20170116/_status //查看导出备份状态,DONE标示已经完成

curl -XDELETE http://127.0.01:9500/_snapshot/my_backup/snapshot_20170116 //删除正在导出的备份(取消备份)

4、迁移备份

scp || sync A -> B (B集群中的所有节点都需要同步)

5、恢复备份(导入)

curl -XPOST http://127.0.0.1:9200/_snapshot/my_backup/snapshot_20170116/_restore?wait_for_completion=true

标签: none

评论已关闭