elasticsearch分片分配和路由配置

本文详细介绍了Elasticsearch 7.3版本中的分片分配和路由配置,包括集群级别的分片分配参数如`cluster.routing.allocation.enable`、`cluster.routing.allocation.node_concurrent_incoming_recoveries`等,以及与恢复相关的参数和分片Rebalance配置。此外,还讨论了基于磁盘的分片分配策略和基于awareness的分片分配,以及如何设置磁盘使用率限制和集群只读模式。最后提到了持久化任务分配的相关设置和注意事项。
摘要由CSDN通过智能技术生成

本文基于es7.3版本。
集群级别的分片分配配置,主要有下面几个:

cluster.routing.allocation.enable:启用或禁止特定种类分片的分配。有下面四种取值:

  • all - (default) Allows shard allocation for all kinds of shards.允许所有种类分片的分配,包括primary和replica。默认行为。
  • primaries - Allows shard allocation only for primary shards.仅允许primary分片的分配,节点重启后,replica的分片不恢复。
  • new_primaries - Allows shard allocation only for primary shards for new indices.仅允许新建索引的primary分片的分配。测试了一下,貌似与上面的区别不大。
  • none - No shard allocations of any kind are allowed for any indices.不允许任何种类分片的分配。新建的索引也不会分配primary和replica分片。

仅影响变化的分片。默认情况下,集群中某个节点失败后,此节点上的shard会恢复到其他节点上,设置非all值,会导致失败节点上shard不会恢复到其他节点。这在集群维护时非常有用,避免了节点重启时,分片在节点间移动的开销。需要注意的是,无论何种取值,节点重启后,如果此节点上存在某分片的replica copy,并且集群中没有此分片的primary copy,则此replica copy会恢复为primary copy。另外,即使在none下,新建索引不分配任何分片,但是集群重启后,仍然会分配primary分片。

cluster.routing.allocation.node_concurrent_incoming_recoveries:单个节点的入口并发恢复的分片数量。表示此节点作为恢复目标节点,分片在其他节点或者是由于Rebalance或者是由于其他节点失败,导致需要在此节点上恢复分片。默认是2个并发分片。

cluster.routing.allocation.node_concurrent_outgoing_recoveries:单个几点的出口并发恢复的分片数量。表示此节点作为恢复的源节点,由于Rebalance导致需要从此节点迁移部分分片到其他节点。默认是2个并发分片。

cluster.routing.allocation.node_concurrent_recoveries:用于快速设置上面两个参数,至于这个是总数两个平分,还是分别设置两个限制,目前未知。先留个坑,等我翻看源码再回来填。从下面的代码看,是分别设置。
 

//ThrottlingAllocationDecider.java
public static final int DEFAULT_CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_RECOVERIES = 2;
    public static final int DEFAULT_CLUSTER_ROUTING_ALLOCATION_NODE_INITIAL_PRIMARIES_RECOVERIES = 4;
    public static final String NAME = "throttling";
    public static final Setting<Integer> CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_RECOVERIES_SETTING =
        new Setting<>("cluster.routing.allocation.node_concurrent_recoveries",
            Integer.toString(DEFAULT_CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_RECOVERIES),
            (s) -> Setting.parseInt(s, 0, "cluster.routing.allocation.node_concurrent_recoveries"),
            Property.Dynamic, Property.NodeScope);
    public static final Setting<Integer> CLUSTER_ROUTING_ALLOCATION_NODE_INITIAL_PRIMARIES_RECOVERIES_SETTING =
        Setting.intSetting("cluster.routing.allocation.node_initial_primaries_recoveries",
            DEFAULT_CLUSTER_ROUTING_ALLOCATION_NODE_INITIAL_PRIMARIES_RECOVERIES, 0,
            Property.Dynamic, Property.NodeScope);
    public static final Setting<Integer> CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_INCOMING_RECOVERIES_SETTING =
        new Setting<>("cluster.routing.allocation.node_concurrent_incoming_recoveries",
            CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_RECOVERIES_SETTING::getRaw,
            (s) -> Setting.parseInt(s, 0, "cluster.routing.allocation.node_concurrent_incoming_recoveries"),
            Property.Dynamic, Property.NodeScope);
    public static final Setting<Integer> CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_OUTGOING_RECOVERIES_SETTING =
        new Setting<>("cluster.routing.allocation.node_concurrent_outgoing_recoveries",
            CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_RECOVERIES_SETTING::getRaw,
            (s) -> Setting.parseInt(s, 0, "cluster.routing.allocation.node_concurrent_outgoing_rec
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值