Index Recovery API (인덱스 리커버리 API)
Recovery API는 하나 이상의 인덱스에 대한 완료되었거나 진행 중인 샤드 리커버리(shard recovery) 정보를 제공하는 API예요. 데이터 스트림을 지정하면 해당 데이터 스트림의 백킹 인덱스에 대한 정보를 반환합니다.
샤드 리커버리는 스냅샷에서 프라이머리 샤드를 복원하거나 복제본 샤드를 동기화하기 위해 샤드 사본을 만드는 과정이에요. 샤드 리커버리 과정이 완료되면 복구된 샤드는 검색 및 인덱스 작업에 사용할 수 있게 됩니다.
샤드 리커버리는 다음 시나리오에서 자동으로 발생합니다.
- 노드 시작(local store recovery라고도 함)
- 프라이머리 샤드의 복제
- 같은 클러스터 내 다른 노드로 샤드 이동(relocation)
- 스냅샷 복원
- clone, shrink, split 작업
Recovery API는 클러스터에 현재 저장되어 있는 샤드 사본에 대한 완료된 리커버리에 대해서만 보고해요. 각 샤드 사본의 가장 최근 리커버리만 보고하며, 이전 리커버리에 대한 이력 정보나 더 이상 존재하지 않는 샤드 사본의 리커버리 정보는 포함하지 않습니다. 따라서 샤드 사본이 리커버리를 완료한 후 다른 노드로 이동하면 원래 리커버리에 대한 정보는 Recovery API에 표시되지 않습니다.
출처: OpenSearch 문서
본문
Endpoints
GET /_recovery GET / { index } /_recovery/
Path parameters
| Parameter | Data type | Description |
|---|---|---|
index |
String | A comma-separated list of indexes, data streams, or index aliases to which the operation is applied. Supports wildcard expressions (*). Use _all or * to specify all indexes and data streams in a cluster. |
Query parameters
다음 쿼리 파라미터는 모두 선택 사항입니다.
| Parameter | Data type | Description |
|---|---|---|
active_only |
Boolean | When true, the response only includes active shard recoveries. Default is false. |
detailed |
Boolean | When true, provides detailed information about shard recoveries. Default is false. |
index |
String | A comma-separated list or wildcard expression of index names used to limit the request. |
Example requests
다음 예제들은 Recovery API를 사용해 리커버리 정보를 가져오는 방법을 보여줍니다.
Recover information from several or all indexes
다음 예제 요청은 여러 인덱스에 대한 리커버리 정보를 사람이 읽기 좋은 형식으로 반환합니다.
GET /index 1 ,index 2 /_recovery?human
response = client . indices . recovery ( index = " index1,index2 " , params = { " human " : " true " } )
다음 예제 요청은 모든 인덱스에 대한 리커버리 정보를 사람이 읽기 좋은 형식으로 반환합니다.
GET /_recovery?human
response = client . indices . recovery ( params = { " human " : " true " } )
Recover detailed information
다음 예제 요청은 상세 리커버리 정보를 반환합니다.
GET /_recovery?human&detailed= true
response = client . indices . recovery ( params = { " human " : " true " , " detailed " : " true " } )
Example response
다음 응답은 shakespeare라는 인덱스에 대한 상세 리커버리 정보를 반환합니다.
{ "shakespeare" : { "shards" : [ { "id" : 0 , "type" : "EXISTING_STORE" , "stage" : "DONE" , "primary" : true , "start_time" : "2024-07-01T18:06:47.415Z" , "start_time_in_millis" : 1719857207415 , "stop_time" : "2024-07-01T18:06:47.538Z" , "stop_time_in_millis" : 1719857207538 , "total_time" : "123ms" , "total_time_in_millis" : 123 , "source" : { "bootstrap_new_history_uuid" : false }, "target" : { "id" : "uerS7REgRQCbBF3ImY8wOQ" , "host" : "172.18.0.3" , "transport_address" : "172.18.0.3:9300" , "ip" : "172.18.0.3" , "name" : "opensearch-node2" }, "index" : { "size" : { "total" : "17.8mb" , "total_in_bytes" : 18708764 , "reused" : "17.8mb" , "reused_in_bytes" : 18708764 , "recovered" : "0b" , "recovered_in_bytes" : 0 , "percent" : "100.0%" }, "files" : { "total" : 7 , "reused" : 7 , "recovered" : 0 , "percent" : "100.0%" , "details" : [ { "name" : "_1.cfs" , "length" : "9.8mb" , "length_in_bytes" : 10325945 , "reused" : true , "recovered" : "0b" , "recovered_in_bytes" : 0 }, { "name" : "_0.cfe" , "length" : "479b" , "length_in_bytes" : 479 , "reused" : true , "recovered" : "0b" , "recovered_in_bytes" : 0 }, { "name" : "_0.si" , "length" : "333b" , "length_in_bytes" : 333 , "reused" : true , "recovered" : "0b" , "recovered_in_bytes" : 0 }, { "name" : "_1.cfe" , "length" : "479b" , "length_in_bytes" : 479 , "reused" : true , "recovered" : "0b" , "recovered_in_bytes" : 0 }, { "name" : "_1.si" , "length" : "333b" , "length_in_bytes" : 333 , "reused" : true , "recovered" : "0b" , "recovered_in_bytes" : 0 }, { "name" : "_0.cfs" , "length" : "7.9mb" , "length_in_bytes" : 8380790 , "reused" : true , "recovered" : "0b" , "recovered_in_bytes" : 0 }, { "name" : "segments_3" , "length" : "405b" , "length_in_bytes" : 405 , "reused" : true , "recovered" : "0b" , "recovered_in_bytes" : 0 } ] }, "total_time" : "6ms" , "total_time_in_millis" : 6 , "source_throttle_time" : "-1" , "source_throttle_time_in_millis" : 0 , "target_throttle_time" : "-1" , "target_throttle_time_in_millis" : 0 }, "translog" : { "recovered" : 0 , "total" : 0 , "percent" : "100.0%" , "total_on_start" : 0 , "total_time" : "113ms" , "total_time_in_millis" : 113 }, "verify_index" : { "check_index_time" : "0s" , "check_index_time_in_millis" : 0 , "total_time" : "0s" , "total_time_in_millis" : 0 } }, { "id" : 0 , "type" : "PEER" , "stage" : "DONE" , "primary" : false , "start_time" : "2024-07-01T18:06:47.693Z" , "start_time_in_millis" : 1719857207693 , "stop_time" : "2024-07-01T18:06:47.744Z" , "stop_time_in_millis" : 1719857207744 , "total_time" : "50ms" , "total_time_in_millis" : 50 , "source" : { "id" : "uerS7REgRQCbBF3ImY8wOQ" , "host" : "172.18.0.3" , "transport_address" : "172.18.0.3:9300" , "ip" : "172.18.0.3" , "name" : "opensearch-node2" }, "target" : { "id" : "HFYKietmTO6Ud9COgP0k9Q" , "host" : "172.18.0.2" , "transport_address" : "172.18.0.2:9300" , "ip" : "172.18.0.2" , "name" : "opensearch-node1" }, "index" : { "size" : { "total" : "0b" , "total_in_bytes" : 0 , "reused" : "0b" , "reused_in_bytes" : 0 , "recovered" : "0b" , "recovered_in_bytes" : 0 , "percent" : "0.0%" }, "files" : { "total" : 0 , "reused" : 0 , "recovered" : 0 , "percent" : "0.0%" , "details" : [] }, "total_time" : "1ms" , "total_time_in_millis" : 1 , "source_throttle_time" : "-1" , "source_throttle_time_in_millis" : 0 , "target_throttle_time" : "-1" , "target_throttle_time_in_millis" : 0 }, "translog" : { "recovered" : 0 , "total" : 0 , "percent" : "100.0%" , "total_on_start" : -1 , "total_time" : "42ms" , "total_time_in_millis" : 42 }, "verify_index" : { "check_index_time" : "0s" , "check_index_time_in_millis" : 0 , "total_time" : "0s" , "total_time_in_millis" : 0 } } ] } }
Response body fields
API는 리커버리 샤드에 대해 다음 정보를 응답합니다.
| Parameter | Data type | Description |
|---|---|---|
id |
Integer | The ID of the shard. |
type |
String | The recovery source for the shard. Returned values include: - EMPTY_STORE: An empty store. Indicates a new primary shard or the forced allocation of an empty primary shard using the Cluster Reroute API. - EXISTING_STORE: The store of an existing primary shard. Indicates that the recovery is related to node startup or the allocation of an existing primary shard. - LOCAL_SHARDS: Shards belonging to another index on the same node. Indicates that the recovery is related to a clone, shrink, or split operation. - PEER: A primary shard on another node. Indicates that the recovery is related to shard replication. - SNAPSHOT: A snapshot. Indicates that the recovery is related to a snapshot restore operation. |
STAGE |
String | The recovery stage. Returned values can include: - INIT: Recovery has not started. - INDEX: Reading index metadata and copying bytes from the source to the destination. - VERIFY_INDEX: Verifying the integrity of the index. - TRANSLOG: Replaying the transaction log. - FINALIZE: Cleanup. - DONE: Complete. |
primary |
Boolean | When true, the shard is a primary shard. |
start_time |
String | The timestamp indicating when the recovery started. |
stop_time |
String | The timestamp indicating when the recovery completed. |
total_time_in_millis |
String | The total amount of time taken to recover a shard, in milliseconds. |
source |
Object | The recovery source. This can include a description of the repository (if the recovery is from a snapshot) or a description of the source node. |
target |
Object | The destination node. |
index |
Object | Statistics about the physical index recovery. |
translog |
Object | Statistics about the translog recovery. |
start |
Object | Statistics about the amount of time taken to open and start the index. |
더 알아보기 (Learn more)
샤드 리커버리는 클러스터 안정성과 직결되는 중요한 과정이에요. 리커버리가 오래 걸리거나 실패하면 클러스터 상태에 문제가 있는 것이므로, CAT Recovery API와 함께 이 Recovery API의 상세 정보를 활용해 원인을 진단할 수 있습니다. 리커버리 타입(EMPTY_STORE, PEER, SNAPSHOT 등)을 이해하면 리커버리가 왜 일어났는지 파악하는 데 도움이 됩니다.