赞
踩
环境说明:
es集群数据通过logstash写入数据,通过logstash建立后缀为时间的索引,通过时间后缀进行数据的定时删除操作。
出现问题:
由于是通过logstash自动创建索引,导致分片个数默认为5,副本分片默认为1。在节点个数大于分片个数的情况下,如果个别索引被分配到同一节点,就会导致数据读写性能不是最优,需要调整logstash自动创建索引时的分片个数。
解决办法:
参考:https://www.elastic.co/guide/en/elasticsearch/reference/7.x/config-monitoring-indices.html
使用logstash自动创建的索引是使用模板进行创建的,只需要对模板进行修改即可:
查看模板:
GET _template/logstash
通过put方法对模板进行修改
PUT _template/logstash
{
“index_patterns”: [
“logstash-*”
],
“settings”: {
“index”: {
“number_of_shards”: “20”,
“refresh_interval”: “5s”
}
}
}
延伸
默认使用logstash自动创建索引如下:
output {
elasticsearch {
hosts => ["172.16.32.222:9200","172.16.32.223:9200"]
index => "test-%{+YYYY.MM.dd}"
user => "elastic"
password => "xxxxxxx"
}
}
数据写入es时默认指定的配置 template_name 默认为 logstash,可以按照格式对logstash模板进行修改,或者建立自己的模板。
建议:(仅参考)
每一个分片数据文件小于30GB
每一个索引中的一个分片对应一个节点
节点数大于等于分片数
threadpool相关:
https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/tune-for-indexing-speed.html#_disable_refresh_and_replicas_for_initial_loads
https://elasticsearch.cn/book/elasticsearch_definitive_guide_2.x/dont-touch-these-settings.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-threadpool.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-thread-pool.html
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。