recovery命令用于查看索引分片的恢复情况,无论是正在进行中的还是已经完成的所有情况;它是JSON recovery API的更紧凑的显示;当集群中一个索引分片被移动到另一个不同的节点时,recovery事件就会发生;在闪照恢复、备份数改变、节点失败以及节点重启时也会发生;最后一个类型称为:本地存储恢复,这也是一种更常用的在节点重启时从磁盘加载分片数据的方式;
1)以下就是当没有分片数据从一个节点移动到另一个节点时集群恢复的状态:
GET _cat/recovery?v
index shard time type stage source_host source_node target_host target_node repository snapshot files files_recovered files_percent files_total bytes bytes_recovered bytes_percent bytes_total translog_ops translog_ops_recovered translog_ops_percent
twitter 0 13ms store done n/a n/a 127.0.0.1 node-0 n/a n/a 0 0 100% 13 0 0 100% 9928 0 0 100.0%
以上例子中:存储类型为 store,索引 源数据和目标数据在同一节点;也就是他们从启动节点的本地存储数据中读取;
2)接着我们来看看正在恢复中索引情况–通过修改集群的备份数和添加新的节点;
GET _cat/recovery?v&h=i,s,t,ty,st,shost,thost,f,fp,b,bp
返回数据如下:
i s t ty st shost thost f fp b bp
twitter 0 1252ms peer done 192.168.1.1 192.168.1.2 0 100.0% 0 100.0%
其中:i:索引;s:分片;t:用时;ty:类型;st:阶段;shost:源主;thost:目标主机;f:文件;fp:文件的百分比;b:字节;bp:字节百分比;
以上twitter分片由另一个节点来恢复的,且恢复类型为peer。文件和字节的copy是实时测量的;
3)闪照 恢复。假如之前做过索引的备份,那么可以通过 snapshot and restore API进行数据恢复;
GET _cat/recovery?v&h=i,s,t,ty,st,rep,snap,f,fp,b,bp
返回结果:
i s t ty st rep snap f fp b bp
twitter 0 1978ms snapshot done twitter snap_1 79 8.0% 12086 9.0%
4) curl -X GET “localhost:9200/_recovery?human&detailed=true” 会显示详细信息;
以下军事可选项:
detailed Display a detailed view. This is primarily useful for viewing the recovery of physical index files. Default: false.
active_only Display only those recoveries that are currently on-going. Default: false.
输出选项:
Description of output fields:
字段名称 | 描述 |
---|---|
id | 分片id |
type | Recovery type: 1) store ;2) snapshot;3) replica;4)relocating |
stage | Recovery stage: 1)init: Recovery has not started ;2) index: Reading index meta-data and copying bytes from source to destination;3) start: Starting the engine; opening the index for use;) translog: Replaying transaction log;)finalize: Cleanup;)done: Complete |
primary | True if shard is primary, false otherwise |
start_time | Timestamp of recovery start |
stop_time | Timestamp of recovery finish |
total_time_in_millis | Total time to recover shard in milliseconds |
source | Recovery source:1) repository description if recovery is from a snapshot;2)description of source node otherwise |
target | Destination node |
index | Statistics about physical index recovery |
translog | Statistics about translog recovery |
start | Statistics about time to open and start the index |