allocation.asciidoc 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. [[index-modules-allocation]]
  2. == Index Shard Allocation
  3. [float]
  4. === Shard Allocation Filtering
  5. Allow to control allocation if indices on nodes based on include/exclude
  6. filters. The filters can be set both on the index level and on the
  7. cluster level. Lets start with an example of setting it on the cluster
  8. level:
  9. Lets say we have 4 nodes, each has specific attribute called `tag`
  10. associated with it (the name of the attribute can be any name). Each
  11. node has a specific value associated with `tag`. Node 1 has a setting
  12. `node.tag: value1`, Node 2 a setting of `node.tag: value2`, and so on.
  13. We can create an index that will only deploy on nodes that have `tag`
  14. set to `value1` and `value2` by setting
  15. `index.routing.allocation.include.tag` to `value1,value2`. For example:
  16. [source,js]
  17. --------------------------------------------------
  18. curl -XPUT localhost:9200/test/_settings -d '{
  19. "index.routing.allocation.include.tag" : "value1,value2"
  20. }'
  21. --------------------------------------------------
  22. On the other hand, we can create an index that will be deployed on all
  23. nodes except for nodes with a `tag` of value `value3` by setting
  24. `index.routing.allocation.exclude.tag` to `value3`. For example:
  25. [source,js]
  26. --------------------------------------------------
  27. curl -XPUT localhost:9200/test/_settings -d '{
  28. "index.routing.allocation.exclude.tag" : "value3"
  29. }'
  30. --------------------------------------------------
  31. `index.routing.allocation.require.*` can be used to
  32. specify a number of rules, all of which MUST match in order for a shard
  33. to be allocated to a node. This is in contrast to `include` which will
  34. include a node if ANY rule matches.
  35. The `include`, `exclude` and `require` values can have generic simple
  36. matching wildcards, for example, `value1*`. A special attribute name
  37. called `_ip` can be used to match on node ip values.
  38. Obviously a node can have several attributes associated with it, and
  39. both the attribute name and value are controlled in the setting. For
  40. example, here is a sample of several node configurations:
  41. [source,js]
  42. --------------------------------------------------
  43. node.group1: group1_value1
  44. node.group2: group2_value4
  45. --------------------------------------------------
  46. In the same manner, `include`, `exclude` and `require` can work against
  47. several attributes, for example:
  48. [source,js]
  49. --------------------------------------------------
  50. curl -XPUT localhost:9200/test/_settings -d '{
  51. "index.routing.allocation.include.group1" : "xxx"
  52. "index.routing.allocation.include.group2" : "yyy",
  53. "index.routing.allocation.exclude.group3" : "zzz",
  54. "index.routing.allocation.require.group4" : "aaa",
  55. }'
  56. --------------------------------------------------
  57. The provided settings can also be updated in real time using the update
  58. settings API, allowing to "move" indices (shards) around in realtime.
  59. Cluster wide filtering can also be defined, and be updated in real time
  60. using the cluster update settings API. This setting can come in handy
  61. for things like decommissioning nodes (even if the replica count is set
  62. to 0). Here is a sample of how to decommission a node based on `_ip`
  63. address:
  64. [source,js]
  65. --------------------------------------------------
  66. curl -XPUT localhost:9200/_cluster/settings -d '{
  67. "transient" : {
  68. "cluster.routing.allocation.exclude._ip" : "10.0.0.1"
  69. }
  70. }'
  71. --------------------------------------------------
  72. [float]
  73. === Total Shards Per Node
  74. The `index.routing.allocation.total_shards_per_node` setting allows to
  75. control how many total shards for an index will be allocated per node.
  76. It can be dynamically set on a live index using the update index
  77. settings API.