Elasticsearch索引创建快照
[*] Elasticsearch snapshot简介
快照一般建立在一个共享的文件系统上,这样的话有一个节点快照,别的节点也是可以看到的,这样删除的时候也可以同时删除,(在最新版里面创建仓库如果未使用共享文件系统会提示你,在其他节点未找到对应的仓库)。
[*] 注册快照仓库
注意这里的“location”目录必须是“path.repo”里面指定的,或者子目录。
[root@controller
elasticsearch]# curl -XPUT 'http://localhost:9200/_snapshot/my_backup'
-d '{
"type":
"fs",
"settings":
{"location":
"/data1/backup/nginx-log","compress": true}
}'查看快照仓库
“compress ” ——是否压缩
[root@controller
elasticsearch]#curl -XGET 'http://localhost:9200/_snapshot/my_backup?pretty'
-d '{
"my_backup":{
"type":"fs",
"setting":{
"compress":"true",
"location":"/data1/backup/nginx-log"
}}}'
3. 创建快照
[root@es-node2
~]# curl -XPUT "localhost:9200/_snapshot/my_backup/nginx-log" -d '{
> "indices": "nginx-log",
> "include_global_state": false
> }'
查看快照
[root@es-node2
indices]# curl -XGET "localhost:9200/_snapshot/my_backup/nginx-log"?pretty=1
{
"snapshots" : [ {
"snapshot" :
"nginx-log",
"version_id" : 1070199,
"version" : "1.7.1",
"indices" : [
"nginx-access-log" ],
"state" : "SUCCESS",
"start_time" :
"2015-08-25T15:16:46.846Z",
"start_time_in_millis" :
1440515806846,
"end_time" :
"2015-08-25T15:16:47.458Z",
"end_time_in_millis" :
1440515807458,
"duration_in_millis" : 612,
"failures" : [ ],
"shards" : {
"total" : 5,
"failed" : 0,
"successful" : 5
}
} ]}
4. 恢复快照
因为这里快照里只有一个索引所以不管直接恢复全部
[root@controller
indices]# curl -XPOST
"localhost:9200/_snapshot/my_backup/nginx-log/_restore"
{"accepted":true} 当您有多个索引在快照里面,就可以用到下面的方式啦~~~
curl -XPOST "localhost:9200/_snapshot/my_backup/nginx-log/_restore"-d '{
"indices": "index_1,index_2",
"ignore_unavailable":
"true",
"include_global_state":
false,
"rename_pattern":
"index_(.+)",
"rename_replacement":
"restored_index_$1"
}'
5. 删除全部快照
# curl -XDELETE http://127.0.0.1:9200/_snapshot/my_backup/nginx-log
{"acknowledged":true}
http://new.nginxs.net/read.php/post-201602241532/
页:
[1]