Elastic Stack
[ Elasticsearch ] maximum shards open 에러
구티맨
2020. 7. 28. 15:16
logstash에서 elasticsearch로 index 시에 아래와 같은 에러가 발생 되었다.
[2020-07-28T15:01:08,012][WARN ][logstash.outputs.elasticsearch] Could not index event to Elasticsearch. {:status=>400, :action=>["index", {:_id=>nil, :_index=>"spring-logback-2020.07.28", :_type=>"_doc", :routing=>nil}, #<LogStash::Event:0x686a528>], :response=>{"index"=>{"_index"=>"spring-logback-2020.07.28", "_type"=>"_doc", "_id"=>nil, "status"=>400, "error"=>{"type"=>"validation_exception", "reason"=>"Validation Failed: 1: this action would add [2] total shards, but this cluster currently has [1000]/[1000] maximum shards open;"}}}}
현재 노드당 최대 shard 개수가 1000개 인데( cluster.max_shards_per_node ), 1000개가 모두 열려 있어 에러가 발생하였다.
$ curl -XGET {{elastic_host}}:9200/_cluster/settings?include_defaults&flat_settings
{
"persistent": {
"indices.breaker.request.limit": "70%",
"xpack.monitoring.collection.enabled": "true"
},
"transient": {},
"defaults": {
"action.auto_create_index": "true",
"action.destructive_requires_name": "false",
"action.search.shard_count.limit": "9223372036854775807",
"bootstrap.ctrlhandler": "true",
"bootstrap.memory_lock": "false",
"bootstrap.system_call_filter": "true",
"cache.recycler.page.limit.heap": "10%",
"cluster.follower_lag.timeout": "90000ms",
"cluster.indices.close.enable": "true",
"cluster.indices.tombstones.size": "500",
"cluster.info.update.interval": "30s",
"cluster.info.update.timeout": "15s",
"cluster.initial_master_nodes": [
"node-1"
],
"cluster.join.timeout": "60000ms",
"cluster.max_shards_per_node": "1000",
.....
}
}
위에 로그를 보면, event 인덱스를 하는데 2개의 shard가 필요하다고 한다.
실제 elasticsearch의 shard를 카운트 해보면, 1000으로 나온다.
$ curl -s -XGET localhost:9200/_cat/shards | wc -l
1000
그래서 일단 노드당 shard 개수를 최대 5000개로 설정 변경을 해두었다.
curl -XGET {{elastic_host}}:9200/_cluster/settings
그러면, elasticsearch에 event가 정상 인덱스 되기 시작하고, shard 개수도 1010개로 늘어나있다.
$ curl -s -XGET localhost:9200/_cat/shards | wc -l
1010