disk_allocator.asciidoc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. [[disk-based-shard-allocation]]
  2. ==== Disk-based shard allocation settings
  3. [[disk-based-shard-allocation-description]]
  4. // tag::disk-based-shard-allocation-description-tag[]
  5. The disk-based shard allocator ensures that all nodes have enough disk space
  6. without performing more shard movements than necessary. It allocates shards
  7. based on a pair of thresholds known as the _low watermark_ and the _high
  8. watermark_. Its primary goal is to ensure that no node exceeds the high
  9. watermark, or at least that any such overage is only temporary. If a node
  10. exceeds the high watermark then {es} will solve this by moving some of its
  11. shards onto other nodes in the cluster.
  12. NOTE: It is normal for nodes to temporarily exceed the high watermark from time
  13. to time.
  14. The allocator also tries to keep nodes clear of the high watermark by
  15. forbidding the allocation of more shards to a node that exceeds the low
  16. watermark. Importantly, if all of your nodes have exceeded the low watermark
  17. then no new shards can be allocated and {es} will not be able to move any
  18. shards between nodes in order to keep the disk usage below the high watermark.
  19. You must ensure that your cluster has enough disk space in total and that there
  20. are always some nodes below the low watermark.
  21. Shard movements triggered by the disk-based shard allocator must also satisfy
  22. all other shard allocation rules such as
  23. <<cluster-shard-allocation-filtering,allocation filtering>> and
  24. <<forced-awareness,forced awareness>>. If these rules are too strict then they
  25. can also prevent the shard movements needed to keep the nodes' disk usage under
  26. control. If you are using <<data-tiers,data tiers>> then {es} automatically
  27. configures allocation filtering rules to place shards within the appropriate
  28. tier, which means that the disk-based shard allocator works independently
  29. within each tier.
  30. If a node is filling up its disk faster than {es} can move shards elsewhere
  31. then there is a risk that the disk will completely fill up. To prevent this, as
  32. a last resort, once the disk usage reaches the _flood-stage_ watermark {es}
  33. will block writes to indices with a shard on the affected node. It will also
  34. continue to move shards onto the other nodes in the cluster. When disk usage
  35. on the affected node drops below the high watermark, {es} automatically removes
  36. the write block. Refer to <<fix-watermark-errors,Fix watermark errors>> to
  37. resolve persistent watermark errors.
  38. [[disk-based-shard-allocation-does-not-balance]]
  39. [TIP]
  40. ====
  41. It is normal for the nodes in your cluster to be using very different amounts
  42. of disk space. The <<shards-rebalancing-settings,balance>> of the cluster
  43. depends on a combination of factors which includes the number of shards on each
  44. node, the indices to which those shards belong, and the resource needs of each
  45. shard in terms of its size on disk and its CPU usage. {es} must trade off all
  46. of these factors against each other, and a cluster which is balanced when
  47. looking at the combination of all of these factors may not appear to be
  48. balanced if you focus attention on just one of them.
  49. ====
  50. You can use the following settings to control disk-based allocation:
  51. [[cluster-routing-disk-threshold]]
  52. // tag::cluster-routing-disk-threshold-tag[]
  53. `cluster.routing.allocation.disk.threshold_enabled`::
  54. (<<dynamic-cluster-setting,Dynamic>>)
  55. Defaults to `true`. Set to `false` to disable the disk allocation decider. Upon disabling, it will also remove any existing `index.blocks.read_only_allow_delete` index blocks.
  56. // end::cluster-routing-disk-threshold-tag[]
  57. [[cluster-routing-watermark-low]]
  58. // tag::cluster-routing-watermark-low-tag[]
  59. `cluster.routing.allocation.disk.watermark.low` {ess-icon}::
  60. (<<dynamic-cluster-setting,Dynamic>>)
  61. Controls the low watermark for disk usage. It defaults to `85%`, meaning that {es} will not allocate shards to nodes that have more than 85% disk used. It can alternatively be set to a ratio value, e.g., `0.85`. It can also be set to an absolute byte value (like `500mb`) to prevent {es} from allocating shards if less than the specified amount of space is available. This setting has no effect on the primary shards of newly-created indices but will prevent their replicas from being allocated.
  62. // end::cluster-routing-watermark-low-tag[]
  63. `cluster.routing.allocation.disk.watermark.low.max_headroom`::
  64. (<<dynamic-cluster-setting,Dynamic>>) Controls the max headroom for the low watermark (in case of a percentage/ratio value).
  65. Defaults to 200GB when `cluster.routing.allocation.disk.watermark.low` is not explicitly set.
  66. This caps the amount of free space required.
  67. [[cluster-routing-watermark-high]]
  68. // tag::cluster-routing-watermark-high-tag[]
  69. `cluster.routing.allocation.disk.watermark.high` {ess-icon}::
  70. (<<dynamic-cluster-setting,Dynamic>>)
  71. Controls the high watermark. It defaults to `90%`, meaning that {es} will attempt to relocate shards away from a node whose disk usage is above 90%. It can alternatively be set to a ratio value, e.g., `0.9`. It can also be set to an absolute byte value (similarly to the low watermark) to relocate shards away from a node if it has less than the specified amount of free space. This setting affects the allocation of all shards, whether previously allocated or not.
  72. // end::cluster-routing-watermark-high-tag[]
  73. `cluster.routing.allocation.disk.watermark.high.max_headroom`::
  74. (<<dynamic-cluster-setting,Dynamic>>) Controls the max headroom for the high watermark (in case of a percentage/ratio value).
  75. Defaults to 150GB when `cluster.routing.allocation.disk.watermark.high` is not explicitly set.
  76. This caps the amount of free space required.
  77. `cluster.routing.allocation.disk.watermark.enable_for_single_data_node`::
  78. (<<static-cluster-setting,Static>>)
  79. In earlier releases, the default behaviour was to disregard disk watermarks for a single
  80. data node cluster when making an allocation decision. This is deprecated behavior
  81. since 7.14 and has been removed in 8.0. The only valid value for this setting
  82. is now `true`. The setting will be removed in a future release.
  83. [[cluster-routing-flood-stage]]
  84. // tag::cluster-routing-flood-stage-tag[]
  85. `cluster.routing.allocation.disk.watermark.flood_stage` {ess-icon}::
  86. +
  87. --
  88. (<<dynamic-cluster-setting,Dynamic>>)
  89. Controls the flood stage watermark, which defaults to 95%. {es} enforces a read-only index block (`index.blocks.read_only_allow_delete`) on every index that has one or more shards allocated on the node, and that has at least one disk exceeding the flood stage. This setting is a last resort to prevent nodes from running out of disk space. The index block is automatically released when the disk utilization falls below the high watermark. Similarly to the low and high watermark values, it can alternatively be set to a ratio value, e.g., `0.95`, or an absolute byte value.
  90. An example of resetting the read-only index block on the `my-index-000001` index:
  91. [source,console]
  92. --------------------------------------------------
  93. PUT /my-index-000001/_settings
  94. {
  95. "index.blocks.read_only_allow_delete": null
  96. }
  97. --------------------------------------------------
  98. // TEST[setup:my_index]
  99. --
  100. // end::cluster-routing-flood-stage-tag[]
  101. `cluster.routing.allocation.disk.watermark.flood_stage.max_headroom`::
  102. (<<dynamic-cluster-setting,Dynamic>>) Controls the max headroom for the flood stage watermark (in case of a percentage/ratio value).
  103. Defaults to 100GB when
  104. `cluster.routing.allocation.disk.watermark.flood_stage` is not explicitly set.
  105. This caps the amount of free space required.
  106. NOTE: You cannot mix the usage of percentage/ratio values and byte values across
  107. the `cluster.routing.allocation.disk.watermark.low`, `cluster.routing.allocation.disk.watermark.high`,
  108. and `cluster.routing.allocation.disk.watermark.flood_stage` settings. Either all values
  109. are set to percentage/ratio values, or all are set to byte values. This enforcement is
  110. so that {es} can validate that the settings are internally consistent, ensuring that the
  111. low disk threshold is less than the high disk threshold, and the high disk threshold is
  112. less than the flood stage threshold. A similar comparison check is done for the max
  113. headroom values.
  114. [[cluster-routing-flood-stage-frozen]]
  115. // tag::cluster-routing-flood-stage-tag[]
  116. `cluster.routing.allocation.disk.watermark.flood_stage.frozen` {ess-icon}::
  117. (<<dynamic-cluster-setting,Dynamic>>)
  118. Controls the flood stage watermark for dedicated frozen nodes, which defaults to
  119. 95%.
  120. `cluster.routing.allocation.disk.watermark.flood_stage.frozen.max_headroom` {ess-icon}::
  121. (<<dynamic-cluster-setting,Dynamic>>)
  122. Controls the max headroom for the flood stage watermark (in case of a
  123. percentage/ratio value) for dedicated frozen nodes. Defaults to 20GB when
  124. `cluster.routing.allocation.disk.watermark.flood_stage.frozen` is not explicitly
  125. set. This caps the amount of free space required on dedicated frozen nodes.
  126. `cluster.info.update.interval`::
  127. (<<dynamic-cluster-setting,Dynamic>>)
  128. How often {es} should check on disk usage for each node in the
  129. cluster. Defaults to `30s`.
  130. NOTE: Percentage values refer to used disk space, while byte values refer to
  131. free disk space. This can be confusing, since it flips the meaning of high and
  132. low. For example, it makes sense to set the low watermark to 10gb and the high
  133. watermark to 5gb, but not the other way around.
  134. An example of updating the low watermark to at least 100 gigabytes free, a high
  135. watermark of at least 50 gigabytes free, and a flood stage watermark of 10
  136. gigabytes free, and updating the information about the cluster every minute:
  137. [source,console]
  138. --------------------------------------------------
  139. PUT _cluster/settings
  140. {
  141. "persistent": {
  142. "cluster.routing.allocation.disk.watermark.low": "100gb",
  143. "cluster.routing.allocation.disk.watermark.high": "50gb",
  144. "cluster.routing.allocation.disk.watermark.flood_stage": "10gb",
  145. "cluster.info.update.interval": "1m"
  146. }
  147. }
  148. --------------------------------------------------
  149. Concerning the max headroom settings for the watermarks, please note
  150. that these apply only in the case that the watermark settings are percentages/ratios.
  151. The aim of a max headroom value is to cap the required free disk space before hitting
  152. the respective watermark. This is especially useful for servers with larger
  153. disks, where a percentage/ratio watermark could translate to a big free disk space requirement,
  154. and the max headroom can be used to cap the required free disk space amount.
  155. As an example, let us take the default settings for the flood watermark.
  156. It has a 95% default value, and the flood max headroom setting has a default value of 100GB.
  157. This means that:
  158. * For a smaller disk, e.g., of 100GB, the flood watermark will hit at 95%, meaning at 5GB
  159. of free space, since 5GB is smaller than the 100GB max headroom value.
  160. * For a larger disk, e.g., of 100TB, the flood watermark will hit at 100GB of free space.
  161. That is because the 95% flood watermark alone would require 5TB of free disk space, but
  162. that is capped by the max headroom setting to 100GB.
  163. Finally, the max headroom settings have their default values only if their respective watermark
  164. settings are not explicitly set (thus, they have their default percentage values).
  165. If watermarks are explicitly set, then the max headroom settings do not have their default values,
  166. and would need to be explicitly set if they are desired.