<code>本文由“開發者手冊”原創,如需轉載,拿走不謝!/<code>
相關環境
如果您還沒有安裝Logstash,請參考我的另一篇文章:
如果您還沒有部署ES集群,請參考我的另一篇文章:
問題描述
Logstash輸出到ElasticSearch集群報錯如下:
<code>[2020-04-01T16:25:13,923][WARN ][logstash.outputs.elasticsearch][main] Could not index event to Elasticsearch.
{:status=>400, :action=>["index", {:_id=>nil, :_index=>"test-index", :routing=>nil, :_type=>"_doc", :pipeline=>"test-pipeline"},
#<:event:0x3009fcbe>], :response=>{"index"=>{"_index"=>"test-index", "_type"=>"_doc", "_id"=>nil, "status"=>400,
"error"=>{"type"=>"illegal_argument_exception", "reason"=>"Validation Failed: 1: this action would add [10] total shards,
but this cluster currently has [3000]/[3000] maximum shards open;"}}}}/<code>
說明:是由於ElasticSearch集群分片數不足引起的,我的測試ElasticSearch集群有3個節點,每個節點默認分片數是1000,所以共3000。
解決辦法
修改ES集群參數如下:
<code>## 設置分片數為10000
PUT _cluster/settings
{
"transient": {
"cluster": {
"max_shards_per_node": 10000
}
}
}/<code>
結束語
希望我的文章能給您帶來幫助,如果您有什麼疑問,可以給我留言,我會在第一時間給你提供解答。如果您有好的建議或想法,也歡迎給我留言。
閱讀更多 開發者手冊 的文章
關鍵字: ElasticSearch 文章 CentOS