인덱스 복구 API

인덱스 복구 API (Index Recovery API)

1.0부터 도입되었어요.

복구(Recovery) API는 하나 이상의 인덱스에 대한 완료되었거나 진행 중인 샤드 복구 정보를 제공해요. 데이터 스트림이 나열되면 API는 그 데이터 스트림의 백킹 인덱스 정보를 반환해요.

샤드 복구는 프라이머리 샤드를 스냅샷에서 복원하거나 복제본 샤드를 동기화하기 위해 샤드 복사본을 만드는 작업이에요. 샤드 복구 과정이 완료되면 복구된 샤드는 검색과 인덱스 작업에 사용할 수 있게 돼요.

샤드 복구는 다음 시나리오에서 자동으로 발생해요:

  • 노드 시작(로컬 저장소 복구라고 불러요)
  • 프라이머리 샤드의 복제
  • 같은 클러스터의 다른 노드로 샤드 이전
  • 스냅샷 복원
  • clone, shrink, split 작업

복구 API는 현재 클러스터에 저장된 샤드 복사본의 완료된 복구만 보고해요. 각 샤드 복사본의 가장 최근 복구만 보고하며, 이전 복구에 대한 과거 정보나 더 이상 존재하지 않는 샤드 복사본의 복구 정보는 포함하지 않아요. 따라서 샤드 복사본이 복구를 완료한 후 다른 노드로 이전되면 원래 복구에 대한 정보는 복구 API에 표시되지 않아요.

출처: 문서

본문

엔드포인트

GET /_recovery
GET /{index}/_recovery/

경로 파라미터

파라미터 데이터 타입 설명
index String 작업이 적용되는 인덱스, 데이터 스트림, 또는 인덱스 별칭의 쉼표로 구분된 목록이에요. 와일드카드 표현식(*)을 지원해요. 클러스터의 모든 인덱스와 데이터 스트림을 지정하려면 _all 또는 *을 사용해요.

쿼리 파라미터

다음 쿼리 파라미터는 모두 선택사항이에요.

파라미터 데이터 타입 설명
active_only Boolean true이면 응답에 활성 샤드 복구만 포함돼요. 기본값은 false예요.
detailed Boolean true이면 샤드 복구에 대한 상세 정보를 제공해요. 기본값은 false예요.
index String 요청을 제한하는 데 사용하는 인덱스 이름의 쉼표로 구분된 목록 또는 와일드카드 표현식이에요.

요청 예시

다음 예제들은 복구 API를 사용해 정보를 가져오는 방법을 보여줘요.

여러 개 또는 모든 인덱스의 복구 정보

다음 요청 예시는 사람이 읽기 쉬운 형식으로 여러 인덱스의 복구 정보를 반환해요:

GET /index1,index2/_recovery?human

다음 요청 예시는 사람이 읽기 쉬운 형식으로 모든 인덱스의 복구 정보를 반환해요:

GET /_recovery?human

상세 정보 복구

다음 요청 예시는 상세 복구 정보를 반환해요:

GET /_recovery?human&detailed=true

응답 예시

다음 응답은 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
        }
      }
    ]
  }
}

응답 본문 필드

API는 복구 샤드에 대해 다음과 같은 정보로 응답해요.

파라미터 데이터 타입 설명
id Integer 샤드의 ID예요.
type String 샤드의 복구 소스예요. 반환되는 값은 다음과 같아요: EMPTY_STORE(빈 저장소 — 새 프라이머리 샤드 또는 클러스터 재라우팅 API를 사용한 빈 프라이머리 샤드의 강제 할당을 나타내요), EXISTING_STORE(기존 프라이머리 샤드의 저장소 — 노드 시작이나 기존 프라이머리 샤드의 할당과 관련된 복구를 나타내요), LOCAL_SHARDS(같은 노드의 다른 인덱스에 속한 샤드 — clone, shrink, split 작업과 관련된 복구를 나타내요), PEER(다른 노드의 프라이머리 샤드 — 샤드 복제와 관련된 복구를 나타내요), SNAPSHOT(스냅샷 — 스냅샷 복원 작업과 관련된 복구를 나타내요).
STAGE String 복구 단계예요. 반환되는 값은 INIT(복구가 시작되지 않음), INDEX(인덱스 메타데이터를 읽고 소스에서 대상으로 바이트를 복사), VERIFY_INDEX(인덱스 무결성 검증), TRANSLOG(트랜잭션 로그 재생), FINALIZE(정리), DONE(완료)일 수 있어요.
primary Boolean true이면 해당 샤드는 프라이머리 샤드예요.
start_time String 복구가 시작된 시점을 나타내는 타임스탬프예요.
stop_time String 복구가 완료된 시점을 나타내는 타임스탬프예요.
total_time_in_millis String 샤드 복구에 걸린 총 시간(밀리초)이에요.
source Object 복구 소스예요. 스냅샷에서 복구하는 경우 저장소 설명을, 소스 노드 설명을 포함할 수 있어요.
target Object 대상 노드예요.
index Object 물리적 인덱스 복구에 대한 통계예요.
translog Object 트랜스로그 복구에 대한 통계예요.
start Object 인덱스를 열고 시작하는 데 걸린 시간에 대한 통계예요.

필요한 권한

보안 플러그인을 사용한다면 다음 권한이 필요해요: indices:monitor/recovery.

더 알아보기 (Learn more)