allocation.asciidoc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. [[index-modules-allocation]]
  2. == Index Shard Allocation
  3. This module provides per-index settings to control the allocation of shards to
  4. nodes.
  5. [float]
  6. [[shard-allocation-filtering]]
  7. === Shard Allocation Filtering
  8. Shard allocation filtering allows you to specify which nodes are allowed
  9. to host the shards of a particular index.
  10. NOTE: The per-index shard allocation filters explained below work in
  11. conjunction with the cluster-wide allocation filters explained in
  12. <<shards-allocation>>.
  13. It is possible to assign arbitrary metadata attributes to each node at
  14. startup. For instance, nodes could be assigned a `rack` and a `group`
  15. attribute as follows:
  16. [source,sh]
  17. ------------------------
  18. bin/elasticsearch --node.rack rack1 --node.size big <1>
  19. ------------------------
  20. <1> These attribute settings can also be specfied in the `elasticsearch.yml` config file.
  21. These metadata attributes can be used with the
  22. `index.routing.allocation.*` settings to allocate an index to a particular
  23. group of nodes. For instance, we can move the index `test` to either `big` or
  24. `medium` nodes as follows:
  25. [source,json]
  26. ------------------------
  27. PUT test/_settings
  28. {
  29. "index.routing.allocation.include.size": "big,medium"
  30. }
  31. ------------------------
  32. // AUTOSENSE
  33. Alternatively, we can move the index `test` away from the `small` nodes with
  34. an `exclude` rule:
  35. [source,json]
  36. ------------------------
  37. PUT test/_settings
  38. {
  39. "index.routing.allocation.exclude.size": "small"
  40. }
  41. ------------------------
  42. // AUTOSENSE
  43. Multiple rules can be specified, in which case all conditions must be
  44. satisfied. For instance, we could move the index `test` to `big` nodes in
  45. `rack1` with the following:
  46. [source,json]
  47. ------------------------
  48. PUT test/_settings
  49. {
  50. "index.routing.allocation.include.size": "big",
  51. "index.routing.allocation.include.rack": "rack1"
  52. }
  53. ------------------------
  54. // AUTOSENSE
  55. NOTE: If some conditions cannot be satisfied then shards will not be moved.
  56. The following settings are _dynamic_, allowing live indices to be moved from
  57. one set of nodes to another:
  58. `index.routing.allocation.include.{attribute}`::
  59. Assign the index to a node whose `{attribute}` has at least one of the
  60. comma-separated values.
  61. `index.routing.allocation.require.{attribute}`::
  62. Assign the index to a node whose `{attribute}` has _all_ of the
  63. comma-separated values.
  64. `index.routing.allocation.exclude.{attribute}`::
  65. Assign the index to a node whose `{attribute}` has _none_ of the
  66. comma-separated values.
  67. These special attributes are also supported:
  68. [horizontal]
  69. `_name`:: Match nodes by node name
  70. `_ip`:: Match nodes by IP address (the IP address associated with the hostname)
  71. `_host`:: Match nodes by hostname
  72. All attribute values can be specified with wildcards, eg:
  73. [source,json]
  74. ------------------------
  75. PUT test/_settings
  76. {
  77. "index.routing.allocation.include._ip": "192.168.2.*"
  78. }
  79. ------------------------
  80. // AUTOSENSE
  81. [float]
  82. === Total Shards Per Node
  83. The cluster-level shard allocator tries to spread the shards of a single index
  84. across as many nodes as possible. However, depending on how many shards and
  85. indices you have, and how big they are, it may not always be possible to spread
  86. shards evenly.
  87. The following _dynamic_ setting allows you to specify a hard limit on the total
  88. number of shards from a single index allowed per node:
  89. `index.routing.allocation.total_shards_per_node`::
  90. The maximum number of shards (replicas and primaries) that will be
  91. allocated to a single node. Defaults to unbounded.
  92. [WARNING]
  93. =======================================
  94. This setting imposes a hard limit which can result in some shards not
  95. being allocated.
  96. Use with caution.
  97. =======================================