绑定完请刷新页面
取消
刷新

分享好友

×
取消 复制
es备份迁移到另外的机器
2019-08-16 09:04:50

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 --

分享好友

分享这个小栈给你的朋友们,一起进步吧。

Hadoop
创建时间:2020-06-17 14:28:01
Hadoop是一个由Apache基金会所开发的分布式系统基础架构。用户可以在不了解分布式底层细节的情况下,开发分布式程序。充分利用集群的威力进行高速运算和存储。
展开
订阅须知

• 所有用户可根据关注领域订阅专区或所有专区

• 付费订阅:虚拟交易,一经交易不退款;若特殊情况,可3日内客服咨询

• 专区发布评论属默认订阅所评论专区(除付费小栈外)

技术专家

查看更多
  • 栈栈
    专家
戳我,来吐槽~