elasticsearch-5.1.1使用snapshot接口备份索引
如果ES是集群,那么需要使用共享存储,支持的存储有:
a、shared file system
b、S3
c、HDFS
我使用的是第一种,NFS共享文件系统。这里要说一下权限问题,ES一般是使用 elasticsearch 用户启动的,要保证共享目录对 elasticsearch 用户有读写权限,要不然创建仓库和快照的时候会报访问拒绝500错误。
在nfs-server上导出共享目录的权限配置,这里将所有连接用户都压缩为root权限:
# vim /etc/exports
/data02/es 192.168.3.56(rw,sync,all_squash,anonuid=0,anongid=0,no_subtree_check) 192.168.3.57(rw,sync,all_squash,anonuid=0,anongid=0,no_subtree_check) 192.168.3.49(rw,sync,all_squash,anonuid=0,anongid=0,no_subtree_check)
# /etc/init.d/nfs-kernel-server reload
1、创建挂载目录,并给予权限
# mkidr -pv /nh/esbk/my_backup
# chmod 755 /nh/esbk/
# chown elasticsearch.elasticsearch /nh/esbk/
2、挂载共享目录
# vim /etc/fstab
192.168.3.97:/data02/es /nh/esbk/my_backup nfs defaults 0 0
# mount -a
# df -hT
3、修改ES的配置文件,添加仓库路径,重启服务
# vim /etc/elasticsearch/elasticsearch.yml
path.repo: ["/nh/esbk"]
# /etc/init.d/elasticsearch restart
4、注册快照仓库到ES,这里是在 kibana 的 Dev Tools 上操作的,也可以使用 curl 发起请求。
Before any snapshot or restore operation can be performed, a snapshot repository should be registered in Elasticsearch.
After all nodes are restarted, the following command can be used to register the shared file system repository with the name my_backup.
PUT /_snapshot/my_backup
{
"type": "fs",
"settings": {
"compress": true,
"location": "/nh/esbk/my_backup"
}
}
5、查看仓库信息
GET /_snapshot/my_backup
# curl -u elastic -XGET 'http://192.168.3.49:9200/_snapshot/my_backup?pretty'
{
"my_backup" : {
"type" : "fs",
"settings" : {
"compress" : "true",
"location" : "/nh/esbk/my_backup"
}
}
}

6、创建快照
A repository can contain multiple snapshots of the same cluster.
Snapshots are identified by unique names within the cluster.
A snapshot with the name snapshot_1 in the repository my_backup can be created by executing the following command.
PUT /_snapshot/my_backup/snapshot_1
这里发起请求后,会立马返回 true,并在后台执行操作。
如果想等待执行完成之后再返回,可以加一个参数:
PUT /_snapshot/my_backup/snapshot_1?wait_for_completion=true
7、查看刚才创建的快照的信息
Once a snapshot is created information about this snapshot can be obtained using the following command.
GET /_snapshot/my_backup/snapshot_1
{
"snapshots": [
{
"snapshot": "snapshot_1",
"uuid": "xSMRNVMIRHmx_qlhX5fqfg",
"version_id": 5040199,
"version": "5.4.1",
"indices": [
".monitoring-kibana-2-2017.07.05",
".monitoring-kibana-2-2017.07.11",
"zixun-nginx-access-2017.07.12",
".monitoring-logstash-2-2017.07.07",
".monitoring-kibana-2-2017.07.07",
"filebeat-2017.07.07",
".watcher-history-3-2017.07.04",
".watcher-history-3-2017.07.07",
".monitoring-es-2-2017.07.05",
".kibana",
".monitoring-data-2",
".watcher-history-3-2017.06.27",
".monitoring-logstash-2-2017.07.10",
".monitoring-kibana-2-2017.07.10",
".monitoring-es-2-2017.07.08",
".monitoring-logstash-2-2017.07.12",
".monitoring-es-2-2017.07.10",
".watcher-history-3-2017.07.06",
".monitoring-kibana-2-2017.07.09",
".watcher-history-3-2017.07.12",
".watcher-history-3-2017.07.03",
".monitoring-alerts-2",
".monitoring-logstash-2-2017.07.08",
".watcher-history-3-2017.07.01",
".watcher-history-3-2017.07.11",
".watcher-history-3-2017.07.05",
".watcher-history-3-2017.06.29",
".watcher-history-3-2017.06.28",
".monitoring-kibana-2-2017.07.08",
".security",
".monitoring-logstash-2-2017.07.11",
".monitoring-es-2-2017.07.11",
".watcher-history-3-2017.06.30",
".triggered_watches",
".watcher-history-3-2017.07.08",
".monitoring-es-2-2017.07.12",
".watcher-history-3-2017.07.09",
".monitoring-es-2-2017.07.09",
".monitoring-kibana-2-2017.07.12",
".monitoring-kibana-2-2017.07.06",
".watcher-history-3-2017.07.10",
"test",
".monitoring-es-2-2017.07.07",
".monitoring-logstash-2-2017.07.09",
".watches",
".monitoring-es-2-2017.07.06",
".watcher-history-3-2017.07.02"
],
"state": "SUCCESS",
"start_time": "2017-07-12T04:19:08.246Z",
"start_time_in_millis": 1499833148246,
"end_time": "2017-07-12T04:20:04.717Z",
"end_time_in_millis": 1499833204717,
"duration_in_millis": 56471,
"failures": [],
"shards": {
"total": 59,
"failed": 0,
"successful": 59
}
}
]
}
列出一个仓库里的所有快照
All snapshots currently stored in the repository can be listed using the following command:
GET /_snapshot/my_backup/_all
8、删除一个快照
A snapshot can be deleted from the repository using the following command:
DELETE /_snapshot/my_backup/snapshot_1
9、删除一个仓库
A repository can be deleted using the following command:
DELETE /_snapshot/my_backup
10、恢复一个快照(支持恢复部分数据以及恢复过程中修改索引信息,具体细节参考官方文档)
POST /_snapshot/my_backup/snapshot_1/_restore
11、查看快照状态信息(比如正在创建或者创建完成等)
a、列出所有当前正在运行的快照以及显示他们的详细状态信息
A list of currently running snapshots with their detailed status information can be obtained using the following command.
GET /_snapshot/_status
b、查看指定仓库的正在运行的快照以及显示他们的详细状态信息
GET /_snapshot/my_backup/_status
c、查看指定快照的详细状态信息即使不是正在运行
If both repository name and snapshot id are specified, this command will return detailed status information for the given snapshot even if it’s not currently running:
GET /_snapshot/my_backup/snapshot_1/_status
d、支持同时指定多个快照ID查看多个快照的信息
Multiple ids are also supported.
GET /_snapshot/my_backup/snapshot_1,snapshot_2/_status
12、如果要停止一个正在运行的snapshot任务(备份和恢复),将其删除即可。
elasticsearch-5.1.1使用snapshot接口备份索引的更多相关文章
- elasticsearch5使用snapshot接口备份索引
数据备份是一个必须要考虑的问题,官网提供了 snapshot 接口来备份和恢复数据. 先来看看官方说明: 如果ES是集群,那么需要使用共享存储,支持的存储有: a.shared file system ...
- [搜索]ElasticSearch Java Api(一) -添加数据创建索引
转载:http://blog.csdn.net/napoay/article/details/51707023 ElasticSearch JAVA API官网文档:https://www.elast ...
- 接口、索引器、Foreach的本质(学习笔记)
接口 什么是接口? 接口代表一种能力,和抽象类类似但比抽象类的抽象程度更高! 接口的定义: public interface IEat//定义一个接口 { void Eat(string food); ...
- ElasticSearch 7.x 默认不在支持指定索引类型
原文:ElasticSearch 7.x 默认不在支持指定索引类型 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://bl ...
- elasticsearch snapshot快照备份和恢复
环境:mac 使用brew 安装elasticsearch 1.在 /usr/local/etc/elasticsearch/elasticsearch.yml 文件中配置快照地址 p ...
- hbase snapshot 表备份/恢复
snapshot其实就是一组metadata信息的集合,它可以让管理员将表恢复到以前的一个状态.snapshot并不是一份拷贝,它只是一个文件名的列表,并不拷贝数据.一个全的snapshot恢复以为着 ...
- Elasticsearch(5)--- 基本命令(集群相关命令、索引CRUD命令、文档CRUD命令)
Elasticsearch(5)--- 基本命令 这篇博客的命令分为ES集群相关命令,索引CRUD命令,文档CRUD命令.这里不包括Query查询命令,它单独写一篇博客. 一.ES集群相关命令 ES集 ...
- elasticsearch 口水篇(6) Mapping 定义索引
前面我们感觉ES就想是一个nosql数据库,支持Free Schema. 接触过Lucene.solr的同学这时可能会思考一个问题——怎么定义document中的field?store.index.a ...
- es备份索引
1.解压https://github.com/medcl/esm-abandonedhttps://github.com/medcl/esm-abandoned/releases tar xf lin ...
随机推荐
- 基于百度地图SDK和Elasticsearch GEO查询的地理围栏分析系统(3)-前端实现
转载自:http://www.cnblogs.com/Auyuer/p/8086975.html MoonLight可视化订单需求区域分析系统实现功能: 在现实生活中,计算机和互联网迅速发展,人们越来 ...
- Ubuntu 安装 Nginx 实现反向代理
安装Nginx依赖库(ubuntu平台) 最近域名通过了备案, 想着应用总不能带着端口号访问吧, 于是在网上踩了很多坑, 终于找到了一步直达的方法,起码这一次很顺利的实现了 安装gcc g++的依赖库 ...
- Css的优先级机制
样式的优先级 多重样式(Multiple Style):如果外部样式.内部样式.内联样式同时应用于同一个元素,就是使用多重样式的情况. 一般情况优先级如下: (外部样式)External style ...
- golang变量作用域问题-避免使用全局变量
最近遇到了一个变量作用域的问题,一个比较低级的问题,可能作为一个熟手不应该犯这样的低级错误,但是golang的语法特点可能让你稍微不注意就踩坑,嘿嘿. 变量作用域 全局变量的作用域是整个包,局部变量的 ...
- DNS服务器解析域名的过程
最近在读许令波老师的<深入分析Java Web技术内幕>,算是对DNS服务器域名解析有个大体的理解,以下的内容来自个人对书中内容的整理 1.什么是域名解析? 当我们在浏览器的地址栏输入一个 ...
- tomcat-users.xml 配置
一:tomcat6配置管理员信息 1:打开tomcat6下的~/conf/tomcat-users.xml文件,关于用户角色.管理员的信息都在这个配置文件中. 2:在配置文件<tomcat-us ...
- 通俗化理解Spring3 IoC的原理和主要组件(spring系列知识二总结)
♣什么是IoC? ♣通俗化理解IoC原理 ♣IoC好处 ♣工厂模式 ♣IoC的主要组件 ♣IoC的应用实例 ♣附:实例代码 1.什么是IoC(控制反转)? Spring3框架的核心是实现控制反转(Io ...
- Ubuntu14.04 命令行下安装teamviewer
下载teamviewer 链接:https://pan.baidu.com/s/1hs0BppM 密码:sdmk 上传到 /home/[user] cd /home/[user] 移动安装包到 /o ...
- 给你的jQuery项目赋予Router技能吧
现在你不会React/Vue都不好意思说自己是前端,不过我相信很多前端项目还是基于jquery类库的传统模式的,假如你有追求的态度使用过requireJs这个库,你一定思考过一个问题,或者说一种组件化 ...
- BZOJ 3787: Gty的文艺妹子序列 [分块 树状数组!]
传送门 题意:单点修改,询问区间内逆序对数,强制在线 看到加了!就说明花了不少时间.... 如果和上题一样预处理信息,用$f[i][j]$表示块i到j的逆序对数 强行修改的话,每个修改最多会修改$(\ ...