未创建每日索引



在我的一台测试服务器上,有8G RAM(从195m到JVM)和es v 7.4,我有12个应用程序索引和几个系统索引,比如每天创建(. monitoring-7-2021.08.02, . monitor-logstash-7-2021.08.02, . monitor-kibana7-2021.08.02)。因此,我可以看到平均每天创建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;

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 - silent -XGET -u elastic:xxxx http://localhost:9200/_cat/shards | grep 'UNASSIGNED'

.
.
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个分片作为分片限制吗?这样我就不会遇到上面提到的分片问题了。

谢谢,

您有很多未分配的分片(可能是因为您有一个节点并且所有索引都有副本=1),因此通过运行以下命令

可以轻松地删除所有分片并同时消除错误
PUT _all/_settings
{
"index.number_of_replicas": 0
} 

关于索引的计数,如果这些索引保持较小(即每个索引低于10GB),您可能不必每天创建一个索引。因此,默认的1000个分片数量已经足够了,而无需更改任何内容。

你应该简单地利用索引生命周期管理来保持你的索引大小,而不是创建太多的小索引。

最新更新