Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6549084
  • 博文数量: 1005
  • 博客积分: 8199
  • 博客等级: 中将
  • 技术积分: 13071
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-25 20:19
个人简介

脚踏实地、勇往直前!

文章分类

全部博文(1005)

文章存档

2020年(2)

2019年(93)

2018年(208)

2017年(81)

2016年(49)

2015年(50)

2014年(170)

2013年(52)

2012年(177)

2011年(93)

2010年(30)

分类: 大数据

2019-08-15 14:09:03


1.在原来的机器上进行备份(我这里备份只保留2天,所以多了些处理脚本)
##创建备份仓库目录
curl -H "Content-Type: application/json" -XPUT -d'{
    "type": "fs", 
    "settings": {
        "location": "/home/yeemiao/single_elasticsearch/esbak"
    }
}'

##备份
curl -H "Content-Type: application/json" -XPUT /snapshot_20190815

2.查看备份情况
curl -X GET "/_all?pretty"
我这里已经有备份,查看备份情况
[yeemiao@localhost esbak]$ curl -X GET "/_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 ''
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size

执行恢复步骤
6.1 创建备份指定目录
curl -H "Content-Type: application/json" -XPUT -d'{
    "type": "fs", 
    "settings": {
        "location": "/home/yeemiao/single_elasticsearch/esbak"
    }
}'

6.2 查看备份信息,这个时候备份信息已经注册进来了
curl -X GET "/_all?pretty"

6.3 执行恢复
curl -XPOST /snapshot_20190815/_restore


7.验证
[yeemiao@localhost esbak]$ curl -X GET ''
这里输出查看到跟原来的主机结果一致

-- The End --
阅读(6877) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~