elasticsearch 快照及从快照中恢复数据
2016-04-14 00:00
495 查看
集群使用sanpshot快照需要共享文件系统,所以要先配置个nfs
####elastichsearch配置
实验使用1.6的elasticsearch,发现需要在master的elasticsearch.yml中添加path.repo:/data/app/snapshot后重启es后才能创建仓库
####安装nfs
# yum install nfs-utils -y
# mkdir /data/app/es_snapshot
# vi /etc/exports
# setenforce 0
# service rpcbind start
# service nfs start
####所有es挂载nfs
# mkdir -p /data/app/snapshot
# yum install nfs-utils -y
# mount 192.168.10.94:/data/app/es_snapshot/ /data/app/snapshot/
####开启快照
查看快照仓库
快照仓库为空
# curl http://192.168.10.91:9200/_snapshot/
{}
创建快照,设置快照目录
# curl -XPUT http://192.168.10.91:9200/_snapshot/snapshot1 -d '{"type":"fs","settings":{"location":"/data/app/snapshot/","compress":"true"}}'
再次查询仓库
# curl http://192.168.10.91:9200/_snapshot/
快照备份
# curl -XPUT http://192.168.10.91:9200/_snapshot/snapshot1/backup1?wait_for_completion=true #等待快照完成后返回
查看快照
# curl http://192.168.10.91:9200/_snapshot/snapshot1/_all?pretty=true
删除快照
# curl -XDELETE http://192.168.10.91:9200/_snapshot/snapshot1/backup1
从快照恢复
# curl -XDELETE http://192.168.10.91:9200/* 删除重名的index,不然恢复会报错
# curl -XPOST http://192.168.10.91:9200/_snapshot/snapshot1/backup2/_restore?wait_for_completion=true #恢复
####elastichsearch配置
实验使用1.6的elasticsearch,发现需要在master的elasticsearch.yml中添加path.repo:/data/app/snapshot后重启es后才能创建仓库
####安装nfs
# yum install nfs-utils -y
# mkdir /data/app/es_snapshot
# vi /etc/exports
/data/app/es_snapshot 192.168.10.*(rw,sync,no_root_squash)
# setenforce 0
# service rpcbind start
# service nfs start
####所有es挂载nfs
# mkdir -p /data/app/snapshot
# yum install nfs-utils -y
# mount 192.168.10.94:/data/app/es_snapshot/ /data/app/snapshot/
####开启快照
查看快照仓库
快照仓库为空
# curl http://192.168.10.91:9200/_snapshot/
{}
创建快照,设置快照目录
# curl -XPUT http://192.168.10.91:9200/_snapshot/snapshot1 -d '{"type":"fs","settings":{"location":"/data/app/snapshot/","compress":"true"}}'
{"acknowledged":true}
再次查询仓库
# curl http://192.168.10.91:9200/_snapshot/
{"snapshot1":{"type":"fs","settings":{"compress":"true","location":"/data/app/snapshot/"}}}
快照备份
# curl -XPUT http://192.168.10.91:9200/_snapshot/snapshot1/backup1?wait_for_completion=true #等待快照完成后返回
{"snapshot":{"snapshot":"backup1","indices":["index1","index2"],"state":"SUCCESS","start_time":"2016-04-14T14:21:41.094Z","start_time_in_millis":1460643701094,"end_time":"2016-04-14T14:21:41.545Z","end_time_in_millis":1460643701545,"duration_in_millis":451,"failures":[],"shards":{"total":10,"failed":0,"successful":10}}}
查看快照
# curl http://192.168.10.91:9200/_snapshot/snapshot1/_all?pretty=true
"snapshots" : [ { "snapshot" : "backup1", "indices" : [ "index1", "index2" ], "state" : "SUCCESS", "start_time" : "2016-04-14T14:21:41.094Z", "start_time_in_millis" : 1460643701094, "end_time" : "2016-04-14T14:21:41.545Z", "end_time_in_millis" : 1460643701545, "duration_in_millis" : 451, "failures" : [ ], "shards" : { "total" : 10, "failed" : 0, "successful" : 10 } }, { "snapshot" : "backup2", "indices" : [ "index1", "index2" ], "state" : "SUCCESS", "start_time" : "2016-04-14T14:22:02.182Z", "start_time_in_millis" : 1460643722182, "end_time" : "2016-04-14T14:22:02.366Z", "end_time_in_millis" : 1460643722366, "duration_in_millis" : 184, "failures" : [ ], "shards" : { "total" : 10, "failed" : 0, "successful" : 10 } } ] }
删除快照
# curl -XDELETE http://192.168.10.91:9200/_snapshot/snapshot1/backup1
{"acknowledged":true}
从快照恢复
# curl -XDELETE http://192.168.10.91:9200/* 删除重名的index,不然恢复会报错
# curl -XPOST http://192.168.10.91:9200/_snapshot/snapshot1/backup2/_restore?wait_for_completion=true #恢复
{"snapshot":{"snapshot":"backup2","indices":["index1","index2"],"shards":{"total":10,"failed":0,"successful":10}}}
相关文章推荐
- C++获得vector最后一个元素
- Hibernate各种主键生成策略与配置详解
- VIEWGOOD(远古)图书馆的资源融合与共享应用解决方案
- CentOS6.5安装Docker
- curl笔记
- 计算两个日期相差几个月
- centos 挂载与卸载硬盘
- 【BoneCP】 com.jolbox.bonecp.BoneCP - Unable to star
- 查看某个进程执行的线程数
- 如何设置Session的有效期?
- 问题解决:The project cannot be built until build path
- POI的简单使用
- mongo-java-driver 的复杂查询
- 快速排序
- 直接选择排序
- SDL使用framebuffer
- [Linux]nvidia optimus在linux下使用
- HTML5 doctype
- 语言属性
- IE 兼容模式