Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

ELK5.4 modifies the number of fragments and the way they are allocated

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

1. Modify the number of fragments

The default number of fragments for elasticsearch is 5 and the number of copies is 1. If you need to modify the number of fragments, there are two ways

1. Modify the index settings

View index status: curl-GET "http://localhost:9200/index/__settings"

Modify index status information:

Curl-XPUT 'localhost:9200/index/_settings'-d' {"index": {"number_of_replicas": 6, "number_of_replicas": 2}}'

This approach can only be modified individually for an index. If you need to modify all indexes uniformly, you need to modify the template information

2. Modify the template

# get default template information

Curl-XGET http://localhost:9200/_template/logstash

# Delete default template

Curl-XDELETE http://localhost:9200/_template/logstash

# upload the modified default template

Curl-XPUT http://localhost:9200/_template/logstash-d'{"template": "logstash-*", "settings": {"index": {"number_of_replicas": "2", "number_of_shards": "6", "refresh_interval": "5s"}} "mappings": {"_ default_": {"dynamic_templates": [{"message_field": {"path_match": "message" "mapping": {"norms": false, "type": "text"} "match_mapping_type": "string"}, {"string_fields": {"mapping": {"norms": false "type": "text" "fields": {"keyword": {"type": "keyword"} "match_mapping_type": "string", "match": "*"}}], "_ all": {"norms": false "enabled": true}, "properties": {"@ timestamp": {"include_in_all": false, "type": "date"} "geoip": {"dynamic": true, "properties": {"ip": {"type": "ip"} "latitude": {"type": "half_float"}, "location": {"type": "geo_point"} "longitude": {"type": "half_float"}}, "@ version": {"include_in_all": false "type": "keyword"}, "aliases": {}}'

II. Slice distribution

By default, shard shards are roughly balanced, but the allocation of primary main shards is uneven (an ES restart or cluster node change)

Shard Allocation Settingsedit

The following dynamic settings may be used to control shard allocation and recovery:

Cluster.routing.allocation.enable

Enable or disable allocation for specific kinds of shards:

All-(default) Allows shard allocation for all kinds of shards.

Primaries-Allows shard allocation only for primary shards.

New_primaries-Allows shard allocation only for primary shards for new indices.

None-No shard allocations of any kind are allowed for any indices.

The above parameter sets the way in which parts are allocated.

PUT _ cluster/settings {"transient": {"cluster.routing.allocation.enable": primaries}}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report