问题出现:
今天发现elk日志系统没有最新日志了,从filebeat到logstash都看了一遍,没发现问题。最后在看elasticsearch日志时发现如下错误:
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 [3000]/[3000] maximum shards open;
这是因为集群最大shard(分片)数不足引起的。查询资料得知:集群中的每个节点默认限制1000个分片。
解决思路
1、调整索引或分片分配策略
根据设备配置情况,如果已经基本满负荷,可以考虑此类方案,删除不必要索引或分片。
2、调整集群最大分片数
2.1 在elasticsearch.yml中定义
cluster.max_shards_per_node: 10000
2.2 在kibana控制台执行
临时增加分片数(重启后会失效)
PUT _cluster/settings
{
"transient":{
"cluster":{
"max_shards_per_node": 1500
}
}
}
# 永久增加分片数
PUT /_cluster/settings
{
"persistent": {
"cluster": {
"max_shards_per_node":1500
}
}
}
2.3 通过http接口
通过http接口和在kibana中方法类似,但它不需要依赖环境。命令如下:
curl -XPUT http://127.0.0.1:9200/_cluster/settings \
-u user:password \
-H "Content-Type: application/json" \
-d '{"transient":{"cluster":{"max_shards_per_node":1500}}}'
2.4查看设置结果
GET _cluster/settings?pretty