본문 바로가기
Troubleshooting

[Elastic Search] maximum shards open 에러

by 가드 2022. 11. 8.
728x90

문제 발생

정상적으로 Elastic Search에 적재되던 로그들이 언제부터인가 적재가 되지 않기 시작하는 걸 발견하였다.

CloudWatch의 로그 그룹을 Lambda를 통해 Elastic Search에 스트리밍 하는 방식이었기 때문에

CloudWatch 로그 그룹부터 확인하기 시작했다.

CloudWatch 로그가 정상적으로 쌓이고 있는 걸 확인하였고 Lambda를 확인하니 Lambda 함수가 에러가 발생하고 있었다.

Lambda에서 아래와 같은 에러가 발생되고 있었다.

{
    "index": {
        "_index": "[<index_name>]",
        "_type": "_doc",
        "_id": "37156103091093385677066907927746061092930918434506932224",
        "status": 400,
        "error": {
            "type": "illegal_argument_exception",
            "reason": "Validation Failed: 1: this action would add [10] total shards, but this cluster currently has [1992]/[2000] maximum shards open;"
        }
    }
}

 

원인 파악

Elastic Search가 Clustering으로 구성되어서 2대가 운영 중이고 기본적으로 1대랑 샤드 Maximum 개수는 1000개로 설정되어 있다.

그래서 2000개의 샤드 파일이 열려있어서 maxumum shards open 에러가 발생하게 된 이유였다.

 

해결방안

1. 가장 오래된 날짜의 파일들 삭제

- 당장 로그가 쌓이지 않기 때문에 가장 오랜 된 로그 파일부터 삭제하여 로그가 쌓이도록 했다.

 

2. 샤드 파일 수 증가 설정

- "persistent": { "cluster.max_shards_per_node""3000" } }

- max_shards_per_node를 1000에서 3000으로 늘리고 재시작한다.

 

3. 로그 인덱스 파일 삭제 정책 적용.

- Indies에서 "Apply policy"를 선택하여 파일 삭제 정책을 정하도록 하자.

- ex) 30일이 지난 index를 삭제하는 정책

{
 "policy": {
  "description": "delete old indexes",
  "default_state": "hot",
  "states": [
   {
    "name": "hot",
    "actions": [],
    "transitions": [
     {
      "state_name": "delete",
      "conditions": {
       "min_index_age": "30d"
      }
     }
    ]
   },
   {
    "name": "delete",
    "actions": [
     {
      "delete": {}
     }
    ],
    "transitions": []
   }
  ],
  "ism_template": [
   {
    "index_patterns": [
     "logstash-*"
    ]
   }
  ]
 }
}

 

300x250

'Troubleshooting' 카테고리의 다른 글

[JPA] N+1 문제  (1) 2022.11.12
[MySQL] Replication 동기화 시간 문제  (0) 2022.11.08
[Elastic Search] Rejecting mapping update to...  (0) 2022.11.07

댓글