我有一个ELK(Elasticsearch-Kibana)堆栈,其中elasticsearch节点的默认分片值为5.日志以logstash格式(logstash-YYYY.MM.DD
)推送到它,如果我错了,则纠正我 - 按日期索引.
由于我无法在不重建索引的情况下更改现有索引的分片计数,因此我希望在创建下一个索引时将分片数增加到8 .我认为ES-API允许即时持续更改.
我该怎么做呢?
您可以使用Elasticsearch中的"模板管理"功能:http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-templates.html
使用以下命令创建新的logstash模板:
curl -XPUT localhost:9200/_template/logstash -d ' { "template": "logstash-*", "settings": { "number_of_replicas": 1, "number_of_shards": 8, "index.refresh_interval": "5s" }, "mappings": { "_default_": { "_all": { "enabled": true }, "dynamic_templates": [ { "string_fields": { "match": "*", "match_mapping_type": "string", "mapping": { "type": "string", "index": "analyzed", "omit_norms": true, "fields": { "raw": { "type": "string", "index": "not_analyzed", "ignore_above": 256 } } } } } ], "properties": { "@version": { "type": "string", "index": "not_analyzed" }, "geoip": { "type": "object", "dynamic": true, "path": "full", "properties": { "location": { "type": "geo_point" } } } } } } }'
下次创建与您的模式匹配的索引时,将使用您的新设置创建该索引.