Elasticsearch

this action would add [1] total shards, but this cluster currently has [1000]/[1000] maximum shards open

babbeolicoding 2023. 6. 22. 22:14

보통 kibana에서 elasticsearch 로그를 가져와서 화면에 보여주곤 한다.

갑자기 kibana에서 특정 index 값이 나오지 않는다면 elastic 서버에 접속해서

로그를 확인해 보면 아래 오류 메시지가 발생하는 경우가 있다,

 

오류내용

this action would add [1] total shards, but this cluster currently has [1000]/[1000] maximum shards open

 

해당 내용은 elasticsearch에서 사용하는 shard max값이 1000개인데

현재 shard를 다 사용했다는 뜻이다.

 

해결 방법은 간단하다.

shard의 갯수를 늘려주면 된다.

 

Trouble Shooting 방법

#현재 shard 확인
curl --user '{id}:{pw}' localhost:9200/_cat/shards | wc -l
#현재 shard 세팅값 확인
curl -XGET --user '{id}:{pw}' localhost:9200/_cluster/settings?pretty
#shard 3000으로 증설
curl -XPUT --user '{id}:{pw}' localhost:9200/_cluster/settings -H "Content-Type: application/json" -d '{ "persistent": { "cluster.max_shards_per_node": "3000" } }'
#현재 shard 세팅값 확인
curl -XGET --user '{id}:{pw}' localhost:9200/_cluster/settings?pretty

 

이후 elastic log를 확인하면 정상이고

kibana를 확인하면 해당 index가 다시 수집되는 걸 확인할 수 있다.