allocation.asciidoc 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. [[index-modules-allocation]]
  2. == Index Shard Allocation
  3. [float]
  4. [[shard-allocation-filtering]]
  5. === Shard Allocation Filtering
  6. Allows to control the allocation of indices on nodes based on include/exclude
  7. filters. The filters can be set both on the index level and on the
  8. cluster level. Lets start with an example of setting it on the cluster
  9. level:
  10. Lets say we have 4 nodes, each has specific attribute called `tag`
  11. associated with it (the name of the attribute can be any name). Each
  12. node has a specific value associated with `tag`. Node 1 has a setting
  13. `node.tag: value1`, Node 2 a setting of `node.tag: value2`, and so on.
  14. We can create an index that will only deploy on nodes that have `tag`
  15. set to `value1` and `value2` by setting
  16. `index.routing.allocation.include.tag` to `value1,value2`. For example:
  17. [source,js]
  18. --------------------------------------------------
  19. curl -XPUT localhost:9200/test/_settings -d '{
  20. "index.routing.allocation.include.tag" : "value1,value2"
  21. }'
  22. --------------------------------------------------
  23. On the other hand, we can create an index that will be deployed on all
  24. nodes except for nodes with a `tag` of value `value3` by setting
  25. `index.routing.allocation.exclude.tag` to `value3`. For example:
  26. [source,js]
  27. --------------------------------------------------
  28. curl -XPUT localhost:9200/test/_settings -d '{
  29. "index.routing.allocation.exclude.tag" : "value3"
  30. }'
  31. --------------------------------------------------
  32. `index.routing.allocation.require.*` can be used to
  33. specify a number of rules, all of which MUST match in order for a shard
  34. to be allocated to a node. This is in contrast to `include` which will
  35. include a node if ANY rule matches.
  36. The `include`, `exclude` and `require` values can have generic simple
  37. matching wildcards, for example, `value1*`. Additonally, special attribute
  38. names called `_ip`, `_name`, `_id` and `_host` can be used to match by node
  39. ip address, name, id or host name, respectively.
  40. Obviously a node can have several attributes associated with it, and
  41. both the attribute name and value are controlled in the setting. For
  42. example, here is a sample of several node configurations:
  43. [source,js]
  44. --------------------------------------------------
  45. node.group1: group1_value1
  46. node.group2: group2_value4
  47. --------------------------------------------------
  48. In the same manner, `include`, `exclude` and `require` can work against
  49. several attributes, for example:
  50. [source,js]
  51. --------------------------------------------------
  52. curl -XPUT localhost:9200/test/_settings -d '{
  53. "index.routing.allocation.include.group1" : "xxx"
  54. "index.routing.allocation.include.group2" : "yyy",
  55. "index.routing.allocation.exclude.group3" : "zzz",
  56. "index.routing.allocation.require.group4" : "aaa",
  57. }'
  58. --------------------------------------------------
  59. The provided settings can also be updated in real time using the update
  60. settings API, allowing to "move" indices (shards) around in realtime.
  61. Cluster wide filtering can also be defined, and be updated in real time
  62. using the cluster update settings API. This setting can come in handy
  63. for things like decommissioning nodes (even if the replica count is set
  64. to 0). Here is a sample of how to decommission a node based on `_ip`
  65. address:
  66. [source,js]
  67. --------------------------------------------------
  68. curl -XPUT localhost:9200/_cluster/settings -d '{
  69. "transient" : {
  70. "cluster.routing.allocation.exclude._ip" : "10.0.0.1"
  71. }
  72. }'
  73. --------------------------------------------------
  74. [float]
  75. === Total Shards Per Node
  76. The `index.routing.allocation.total_shards_per_node` setting allows to
  77. control how many total shards for an index will be allocated per node.
  78. It can be dynamically set on a live index using the update index
  79. settings API.
  80. [float]
  81. [[disk]]
  82. === Disk-based Shard Allocation
  83. added[1.3.0] disk based shard allocation is enabled from version 1.3.0 onward
  84. Elasticsearch can be configured to prevent shard
  85. allocation on nodes depending on disk usage for the node. This
  86. functionality is enabled by default, and can be changed either in the
  87. configuration file, or dynamically using:
  88. [source,js]
  89. --------------------------------------------------
  90. curl -XPUT localhost:9200/_cluster/settings -d '{
  91. "transient" : {
  92. "cluster.routing.allocation.disk.threshold_enabled" : false
  93. }
  94. }'
  95. --------------------------------------------------
  96. Once enabled, Elasticsearch uses two watermarks to decide whether
  97. shards should be allocated or can remain on the node.
  98. `cluster.routing.allocation.disk.watermark.low` controls the low
  99. watermark for disk usage. It defaults to 85%, meaning ES will not
  100. allocate new shards to nodes once they have more than 85% disk
  101. used. It can also be set to an absolute byte value (like 500mb) to
  102. prevent ES from allocating shards if less than the configured amount
  103. of space is available.
  104. `cluster.routing.allocation.disk.watermark.high` controls the high
  105. watermark. It defaults to 90%, meaning ES will attempt to relocate
  106. shards to another node if the node disk usage rises above 90%. It can
  107. also be set to an absolute byte value (similar to the low watermark)
  108. to relocate shards once less than the configured amount of space is
  109. available on the node.
  110. Both watermark settings can be changed dynamically using the cluster
  111. settings API. By default, Elasticsearch will retrieve information
  112. about the disk usage of the nodes every 30 seconds. This can also be
  113. changed by setting the `cluster.info.update.interval` setting.