Elasticsearch模块功能之-快照和恢复(snapshot and restore)
程序员文章站
2022-05-07 19:28:01
...
Elasticsearch模块功能之-快照和恢复(snapshot and restore)
快照和恢复模块可以将单个索引或者整个集群做一个快照并存放到远程仓库上。目前支持共享文件系统仓库和官方通过插件方式提供的其他仓库。
1、仓库注册
在创建或恢复仓库数据之前,首先需要到ElasticSearch里进行注册,如下命令用my_backup注册一个共享文件系统,快照数据将存放在/mount/backups/my_bakup上:
- $ curl -XPUT 'http://localhost:9200/_snapshot/my_backup' -d '
- "type": "fs",(共享的文件系统仓库)
- "settings": {
- "location": "/mount/backups/my_backup", (快照存放位置)
- "compress": true (快照是否压缩,默认true)
- }
- '
2、查看仓库信息:
- $ curl -XGET 'http://localhost:9200/_snapshot/my_backup?pretty'
- {
- "my_backup" : {
- "type" : "fs",
- "settings" : {
- "compress" : "true",
- "location" : "/mount/backups/my_backup"
- }
- }
- }
3、创建快照
同一个集群中,一个仓库中可以存放多个快照。快照在集群中的名称是唯一的。使用下面命令创建快照名为snapshot_1的快照:
- $ curl -XPUT "localhost:9200/_snapshot/my_backup/snapshot_1"-d '{
- "indices": "index_1,index_2",
- "ignore_unavailable": "true",
- "include_global_state": false
- }'
4、查看快照信息:
- $ curl -XGET "localhost:9200/_snapshot/my_backup/snapshot_1"
5、快照恢复
- $ curl -XPOST "localhost:9200/_snapshot/my_backup/snapshot_1/_restore"-d '{
- "indices": "index_1,index_2",
- "ignore_unavailable": "true",
- "include_global_state": false,
- "rename_pattern": "index_(.+)",
- "rename_replacement": "restored_index_$1"
- }'
6、监控快照创建或恢复过程
- $ curl -XGET "localhost:9200/_snapshot/my_backup/snapshot_1/_status"
- </pre><div style="background:#F0F0F0"><pre>
【参考】:http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index.html
from http://blog.csdn.net/changong28/article/details/38379053