allocation.asciidoc 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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*`. A special attribute name
  38. called `_ip` can be used to match on node ip values.
  39. Obviously a node can have several attributes associated with it, and
  40. both the attribute name and value are controlled in the setting. For
  41. example, here is a sample of several node configurations:
  42. [source,js]
  43. --------------------------------------------------
  44. node.group1: group1_value1
  45. node.group2: group2_value4
  46. --------------------------------------------------
  47. In the same manner, `include`, `exclude` and `require` can work against
  48. several attributes, for example:
  49. [source,js]
  50. --------------------------------------------------
  51. curl -XPUT localhost:9200/test/_settings -d '{
  52. "index.routing.allocation.include.group1" : "xxx"
  53. "index.routing.allocation.include.group2" : "yyy",
  54. "index.routing.allocation.exclude.group3" : "zzz",
  55. "index.routing.allocation.require.group4" : "aaa",
  56. }'
  57. --------------------------------------------------
  58. The provided settings can also be updated in real time using the update
  59. settings API, allowing to "move" indices (shards) around in realtime.
  60. Cluster wide filtering can also be defined, and be updated in real time
  61. using the cluster update settings API. This setting can come in handy
  62. for things like decommissioning nodes (even if the replica count is set
  63. to 0). Here is a sample of how to decommission a node based on `_ip`
  64. address:
  65. [source,js]
  66. --------------------------------------------------
  67. curl -XPUT localhost:9200/_cluster/settings -d '{
  68. "transient" : {
  69. "cluster.routing.allocation.exclude._ip" : "10.0.0.1"
  70. }
  71. }'
  72. --------------------------------------------------
  73. [float]
  74. === Total Shards Per Node
  75. The `index.routing.allocation.total_shards_per_node` setting allows to
  76. control how many total shards for an index will be allocated per node.
  77. It can be dynamically set on a live index using the update index
  78. settings API.
  79. [float]
  80. [[disk]]
  81. === Disk-based Shard Allocation
  82. Elasticsearch con be configured to prevent shard
  83. allocation on nodes depending on disk usage for the node. This
  84. functionality is disabled by default, and can be changed either in the
  85. configuration file, or dynamically using:
  86. [source,js]
  87. --------------------------------------------------
  88. curl -XPUT localhost:9200/_cluster/settings -d '{
  89. "transient" : {
  90. "cluster.routing.allocation.disk.threshold_enabled" : true
  91. }
  92. }'
  93. --------------------------------------------------
  94. Once enabled, Elasticsearch uses two watermarks to decide whether
  95. shards should be allocated or can remain on the node.
  96. `cluster.routing.allocation.disk.watermark.low` controls the low
  97. watermark for disk usage. It defaults to 0.70, meaning ES will not
  98. allocate new shards to nodes once they have more than 70% disk
  99. used. It can also be set to an absolute byte value (like 500mb) to
  100. prevent ES from allocating shards if less than the configured amount
  101. of space is available.
  102. `cluster.routing.allocation.disk.watermark.high` controls the high
  103. watermark. It defaults to 0.85, meaning ES will attempt to relocate
  104. shards to another node if the node disk usage rises above 85%. It can
  105. also be set to an absolute byte value (similar to the low watermark)
  106. to relocate shards once less than the configured amount of space is
  107. available on the node.
  108. Both watermark settings can be changed dynamically using the cluster
  109. settings API. By default, Elasticsearch will retrieve information
  110. about the disk usage of the nodes every 30 seconds. This can also be
  111. changed by setting the `cluster.info.update.interval` setting.