shards.asciidoc 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. [[cat-shards]]
  2. == cat shards
  3. The `shards` command is the detailed view of what nodes contain which
  4. shards. It will tell you if it's a primary or replica, the number of
  5. docs, the bytes it takes on disk, and the node where it's located.
  6. Here we see a single index, with three primary shards and no replicas:
  7. [source,sh]
  8. --------------------------------------------------
  9. % curl 192.168.56.20:9200/_cat/shards
  10. wiki1 0 p STARTED 3014 31.1mb 192.168.56.10 Stiletto
  11. wiki1 1 p STARTED 3013 29.6mb 192.168.56.30 Frankie Raye
  12. wiki1 2 p STARTED 3973 38.1mb 192.168.56.20 Commander Kraken
  13. --------------------------------------------------
  14. [float]
  15. [[index-pattern]]
  16. === Index pattern
  17. If you have many shards, you may wish to limit which indices show up
  18. in the output. You can always do this with `grep`, but you can save
  19. some bandwidth by supplying an index pattern to the end.
  20. [source,sh]
  21. --------------------------------------------------
  22. % curl 192.168.56.20:9200/_cat/shards/wiki2
  23. wiki2 0 p STARTED 197 3.2mb 192.168.56.10 Stiletto
  24. wiki2 1 p STARTED 205 5.9mb 192.168.56.30 Frankie Raye
  25. wiki2 2 p STARTED 275 7.8mb 192.168.56.20 Commander Kraken
  26. --------------------------------------------------
  27. [float]
  28. [[relocation]]
  29. === Relocation
  30. Let's say you've checked your health and you see two relocating
  31. shards. Where are they from and where are they going?
  32. [source,sh]
  33. --------------------------------------------------
  34. % curl 192.168.56.10:9200/_cat/health
  35. 1384315316 20:01:56 foo green 3 3 12 6 2 0 0
  36. % curl 192.168.56.10:9200/_cat/shards | fgrep RELO
  37. wiki1 0 r RELOCATING 3014 31.1mb 192.168.56.20 Commander Kraken -> 192.168.56.30 Frankie Raye
  38. wiki1 1 r RELOCATING 3013 29.6mb 192.168.56.10 Stiletto -> 192.168.56.30 Frankie Raye
  39. --------------------------------------------------
  40. [float]
  41. [[states]]
  42. === Shard states
  43. Before a shard can be used, it goes through an `INITIALIZING` state.
  44. `shards` can show you which ones.
  45. [source,sh]
  46. --------------------------------------------------
  47. % curl -XPUT 192.168.56.20:9200/_settings -d'{"number_of_replicas":1}'
  48. {"acknowledged":true}
  49. % curl 192.168.56.20:9200/_cat/shards
  50. wiki1 0 p STARTED 3014 31.1mb 192.168.56.10 Stiletto
  51. wiki1 0 r INITIALIZING 0 14.3mb 192.168.56.30 Frankie Raye
  52. wiki1 1 p STARTED 3013 29.6mb 192.168.56.30 Frankie Raye
  53. wiki1 1 r INITIALIZING 0 13.1mb 192.168.56.20 Commander Kraken
  54. wiki1 2 r INITIALIZING 0 14mb 192.168.56.10 Stiletto
  55. wiki1 2 p STARTED 3973 38.1mb 192.168.56.20 Commander Kraken
  56. --------------------------------------------------
  57. If a shard cannot be assigned, for example you've overallocated the
  58. number of replicas for the number of nodes in the cluster, the shard
  59. will remain `UNASSIGNED` with the <<reason-unassigned,reason code>> `ALLOCATION_FAILED`.
  60. [source,sh]
  61. --------------------------------------------------
  62. % curl -XPUT 192.168.56.20:9200/_settings -d'{"number_of_replicas":3}'
  63. % curl 192.168.56.20:9200/_cat/health
  64. 1384316325 20:18:45 foo yellow 3 3 9 3 0 0 3
  65. % curl 192.168.56.20:9200/_cat/shards
  66. wiki1 0 p STARTED 3014 31.1mb 192.168.56.10 Stiletto
  67. wiki1 0 r STARTED 3014 31.1mb 192.168.56.30 Frankie Raye
  68. wiki1 0 r STARTED 3014 31.1mb 192.168.56.20 Commander Kraken
  69. wiki1 0 r UNASSIGNED ALLOCATION_FAILED
  70. wiki1 1 r STARTED 3013 29.6mb 192.168.56.10 Stiletto
  71. wiki1 1 p STARTED 3013 29.6mb 192.168.56.30 Frankie Raye
  72. wiki1 1 r STARTED 3013 29.6mb 192.168.56.20 Commander Kraken
  73. wiki1 1 r UNASSIGNED ALLOCATION_FAILED
  74. wiki1 2 r STARTED 3973 38.1mb 192.168.56.10 Stiletto
  75. wiki1 2 r STARTED 3973 38.1mb 192.168.56.30 Frankie Raye
  76. wiki1 2 p STARTED 3973 38.1mb 192.168.56.20 Commander Kraken
  77. wiki1 2 r UNASSIGNED ALLOCATION_FAILED
  78. --------------------------------------------------
  79. [float]
  80. [[reason-unassigned]]
  81. === Reasons for unassigned shard
  82. These are the possible reasons for a shard be in a unassigned state:
  83. [horizontal]
  84. `INDEX_CREATED`:: Unassigned as a result of an API creation of an index.
  85. `CLUSTER_RECOVERED`:: Unassigned as a result of a full cluster recovery.
  86. `INDEX_REOPENED`:: Unassigned as a result of opening a closed index.
  87. `DANGLING_INDEX_IMPORTED`:: Unassigned as a result of importing a dangling index.
  88. `NEW_INDEX_RESTORED`:: Unassigned as a result of restoring into a new index.
  89. `EXISTING_INDEX_RESTORED`:: Unassigned as a result of restoring into a closed index.
  90. `REPLICA_ADDED`:: Unassigned as a result of explicit addition of a replica.
  91. `ALLOCATION_FAILED`:: Unassigned as a result of a failed allocation of the shard.
  92. `NODE_LEFT`:: Unassigned as a result of the node hosting it leaving the cluster.
  93. `REROUTE_CANCELLED`:: Unassigned as a result of explicit cancel reroute command.
  94. `REINITIALIZED`:: When a shard moves from started back to initializing, for example, with shadow replicas.
  95. `REALLOCATED_REPLICA`:: A better replica location is identified and causes the existing replica allocation to be cancelled.