【发布时间】:2021-10-08 21:27:39
【问题描述】:
在具有 es v 7.4 的 8G RAM(1955m 到 JVM)的单个测试服务器上,我有 12 个应用程序索引 + 少数系统索引,例如 (.monitoring-es-7-2021.08.02, .monitoring-logstash-7 -2021.08.02, .monitoring-kibana-7-2021.08.02) 每天创建。所以平均而言,我可以看到每天 es 创建 15 个索引。
今天我可以看到只创建了两个索引。
curl -slient -u elastic:xxxxx 'http://127.0.0.1:9200/_cat/indices?v' -u elastic | grep '2021.08.03'
Enter host password for user 'elastic':
yellow open metricbeat-7.4.0-2021.08.03 KMJbbJMHQ22EM5Hfw 1 1 110657 0 73.9mb 73.9mb
green open .monitoring-kibana-7-2021.08.03 98iEmlw8GAm2rj-xw 1 0 3 0 1.1mb 1.1mb
我认为上面的原因如下,
在查看es日志时,发现
[2021-08-03T12:14:15,394][WARN ][o.e.x.m.e.l.LocalExporter] [elasticsearch_1] unexpected error while indexing monitoring document org.elasticsearch.xpack.monitoring.exporter.ExportException: org.elasticsearch.common.ValidationException: Validation Failed: 1: this action would add [1] total shards, but this cluster currently has [1000]/[1000] maximum shards open;
应用程序索引和filebeat索引的logstash日志
[2021-08-03T05:18:05,246][WARN ][logstash.outputs.elasticsearch][main] Could not index event to Elasticsearch. {:status=>400, :action=>["index", {:_id=>nil, :_index=>"ping_server-2021.08.03", :_type=>"_doc", :routing=>nil}, #LogStash::Event:0x44b98479], :response=>{"index"=>{"_index"=>"ping_server-2021.08.03", "_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;"}}}}
[2021-08-03T05:17:38,230][WARN ][logstash.outputs.elasticsearch][main] Could not index event to Elasticsearch. {:status=>400, :action=>["index", {:_id=>nil, :_index=>"filebeat-7.4.0-2021.08.03", :_type=>"_doc", :routing=>nil}, #LogStash::Event:0x1e2c70a8], :response=>{"index"=>{"_index"=>"filebeat-7.4.0-2021.08.03", "_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;"}}}}
将活动和未分配的分片总数增加到 1000
"active_primary_shards" : 512,
"active_shards" : 512,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 488,
"delayed_unassigned_shards" : 0,
"active_shards_percent_as_number" : 51.2
如果我检查以下命令,我会看到所有未分配的分片都是副本分片
curl -slient -XGET -u elastic:xxxx http://localhost:9200/_cat/shards | grep '未签名'
.
.
dev_app_server-2021.07.10 0 r UNASSIGNED
apm-7.4.0-span-000028 0 r UNASSIGNED
ping_server-2021.07.02 0 r UNASSIGNED
api_app_server-2021.07.17 0 r UNASSIGNED
consent_app_server-2021.07.15 0 r UNASSIGNED
问。那么现在,我可以安全地删除未分配的分片以释放一些分片作为其单节点集群吗?
问。我可以将设置从分配 2 个分片(1 个主分片和 1 个副本)更改为 1 个主分片作为每个在线索引的单个服务器吗?
问。如果我必须保留一年的指数,下面的计算是否正确?
每天 15 个索引,一个主分片 * 365 天 = 5475 个总分片(或者说 6000 个四舍五入)
问。我可以为这个节点设置 6000 个分片作为分片限制,这样我就永远不会遇到提到的分片问题吗?
谢谢,
【问题讨论】:
标签: elasticsearch logstash filebeat