| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 | [[shards-allocation]]=== Cluster Level Shard AllocationShard allocation is the process of allocating shards to nodes. This canhappen during initial recovery, replica allocation, rebalancing, orwhen nodes are added or removed.[float]=== Shard Allocation SettingsThe 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.This setting does not affect the recovery of local primary shards whenrestarting a node.  A restarted node that has a copy of an unassigned primaryshard will recover that primary immediately, assuming that the<<index.recovery.initial_shards,`index.recovery.initial_shards`>> setting issatisfied.--`cluster.routing.allocation.node_concurrent_recoveries`::     How many concurrent shard recoveries are allowed to happen on a node.     Defaults to `2`.`cluster.routing.allocation.node_initial_primaries_recoveries`::    While the recovery of replicas happens over the network, the recovery of    an unassigned primary after node restart uses data from the local disk.    These should be fast so more initial primary recoveries can happen in    parallel on the same node.  Defaults to `4`.`cluster.routing.allocation.same_shard.host`::      Allows to perform a check to prevent allocation of multiple instances of      the same shard on a single host, based on host name and host address.      Defaults to `false`, meaning that no check is performed by default. This      setting only applies if multiple nodes are started on the same machine.`indices.recovery.concurrent_streams`::       The number of network streams to open per node to recover a shard from       a peer shard. Defaults to `3`.`indices.recovery.concurrent_small_file_streams`::       The number of streams to open per node for small files (under 5mb) to       recover a shard from a peer shard. Defaults to `2`.[float]=== Shard Rebalancing SettingsThe following _dynamic_ settings may be used to control the rebalancing ofshards across the cluster:`cluster.routing.rebalance.enable`::+--Enable or disable rebalancing for specific kinds of shards:* `all` -         (default) Allows shard balancing for all kinds of shards.* `primaries` -   Allows shard balancing only for primary shards.* `replicas` -    Allows shard balancing only for replica shards.* `none` -        No shard balancing of any kind are allowed for any indices.--`cluster.routing.allocation.allow_rebalance`::+--Specify when shard rebalancing is allowed:* `always` -                    (default) Always allow rebalancing.* `indices_primaries_active` -  Only when all primaries in the cluster are allocated.* `indices_all_active` -        Only when all shards (primaries and replicas) in the cluster are allocated.--`cluster.routing.allocation.cluster_concurrent_rebalance`::      Allow to control how many concurrent shard rebalances are      allowed cluster wide. Defaults to `2`.[float]=== Shard Balancing HeuristicsThe following settings are used together to determine where to place eachshard.  The cluster is balanced when no allowed action can bring the weightsof each node closer together by more then the `balance.threshold`.`cluster.routing.allocation.balance.shard`::     Defines the weight factor for shards allocated on a node     (float). Defaults to `0.45f`.  Raising this raises the tendency to     equalize the number of shards across all nodes in the cluster.`cluster.routing.allocation.balance.index`::     Defines a factor to the number of shards per index allocated      on a specific node (float). Defaults to `0.55f`.  Raising this raises the      tendency to equalize the number of shards per index across all nodes in      the cluster.`cluster.routing.allocation.balance.threshold`::     Minimal optimization value of operations that should be performed (non      negative float). Defaults to `1.0f`.  Raising this will cause the cluster      to be less aggressive about optimizing the shard balance.NOTE: Regardless of the result of the balancing algorithm, rebalancing mightnot be allowed due to forced awareness or allocation filtering.
 |