ITPub博客

首页 > 大数据 > > es备份迁移到另外的机器

es备份迁移到另外的机器

作者:xiaojun63 时间:2019-08-16 09:04:50 0 删除 编辑

1.在原来的机器上进行备份(我这里备份只保留2天,所以多了些处理脚本)

##创建备份仓库目录

curl -H "Content-Type: application/json" -XPUT http://192.168.1.136:19200/_snapshot/esbackup -d'{

    "type": "fs", 

    "settings": {

        "location": "/home/yeemiao/single_elasticsearch/esbak"

    }

}'

##备份

curl -H "Content-Type: application/json" -XPUT http://192.168.1.136:19200/_snapshot/esbackup/snapshot_20190815

2.查看备份情况

curl -X GET "http://192.168.1.136:19200/_snapshot/esbackup/_all?pretty"

我这里已经有备份,查看备份情况

[yeemiao@localhost esbak]$ curl -X GET "http://192.168.1.136:19200/_snapshot/esbackup/_all?pretty"

{

  "snapshots" : [

    {

      "snapshot" : "snapshot_20190815",

      "uuid" : "jZk8QYgISMmkc1qpNB4BZw",

      "version_id" : 6050099,

      "version" : "6.5.0",

      "indices" : [

        "reservation_hxl",

        "reservation",

        "vacc_update",

        "reservation_new",

        "child_inocexamine_student_inoculation1",

        "child_inocexamine_vacc",

        "hxl_update",

        "bak01_hxl_test",

        "child_inocexamine_student",

        "bak_hxl_test",

        "child_inocexamine_student_inoculation",

        "inoculate_new",

        "update",

        "bak02_hxl_test",

        "inoculate",

        ".security-6"

      ],

      "include_global_state" : true,

      "state" : "IN_PROGRESS",

      "start_time" : "2019-08-15T05:45:40.443Z",

      "start_time_in_millis" : 1565847940443,

      "end_time" : "1970-01-01T00:00:00.000Z",

      "end_time_in_millis" : 0,

      "duration_in_millis" : -1565847940443,

      "failures" : [ ],

      "shards" : {

        "total" : 0,

        "failed" : 0,

        "successful" : 0

      }

    }

  ]

}

3.将es备份目录打包,然后上传到新部署的机器上面

[yeemiao@localhost single_elasticsearch]$ cd /home/yeemiao/single_elasticsearch

tar -czvf esbak20190815.tar ./esbak

scp esbak20190815.tar yeemiao@192.168.1.134:/tmp/

4.新机器安装部署es

安装步骤省略,特别注意如下参数必须跟原来机器一致,因为我们等会将原来机器的备份文件加压到该目录

path.repo: /home/yeemiao/single_elasticsearch/esbak

5.将原主机备份的文件解压到新机器path.repo参数指定的目录

[yeemiao@localhost tmp]$ cd /tmp/

[yeemiao@localhost tmp]$ tar -xvf esbak20190815.tar

[yeemiao@localhost esbak]$ cd /tmp/esbak

[yeemiao@localhost esbak]$ cp -r ./* /home/yeemiao/single_elasticsearch/esbak

6.执行恢复

新的机器这个时候是没有index的

[yeemiao@localhost esbak]$ curl -X GET 'http://192.168.1.134:9200/_cat/indices?v'

health status index uuid pri rep docs.count docs.deleted store.size pri.store.size

执行恢复步骤

6.1 创建备份指定目录

curl -H "Content-Type: application/json" -XPUT http://192.168.1.134:9200/_snapshot/esbackup -d'{

    "type": "fs", 

    "settings": {

        "location": "/home/yeemiao/single_elasticsearch/esbak"

    }

}'

6.2 查看备份信息,这个时候备份信息已经注册进来了

curl -X GET "http://192.168.1.134:9200/_snapshot/esbackup/_all?pretty"

6.3 执行恢复

curl -XPOST http://192.168.1.134:9200/_snapshot/esbackup/snapshot_20190815/_restore

7.验证

[yeemiao@localhost esbak]$ curl -X GET 'http://192.168.1.134:9200/_cat/indices?v'

这里输出查看到跟原来的主机结果一致

-- The End --

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/658/viewspace-3153853/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-04-12

  • 博文量
    243
  • 访问量
    3053