shards.asciidoc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. [[index-pattern]]
  15. === Index pattern
  16. If you have many shards, you may wish to limit which indices show up
  17. in the output. You can always do this with `grep`, but you can save
  18. some bandwidth by supplying an index pattern to the end.
  19. [source,sh]
  20. --------------------------------------------------
  21. % curl 192.168.56.20:9200/_cat/shards/wiki2
  22. wiki2 0 p STARTED 197 3.2mb 192.168.56.10 Stiletto
  23. wiki2 1 p STARTED 205 5.9mb 192.168.56.30 Frankie Raye
  24. wiki2 2 p STARTED 275 7.8mb 192.168.56.20 Commander Kraken
  25. --------------------------------------------------
  26. [[relocation]]
  27. === Relocation
  28. Let's say you've checked your health and you see two relocating
  29. shards. Where are they from and where are they going?
  30. [source,sh]
  31. --------------------------------------------------
  32. % curl 192.168.56.10:9200/_cat/health
  33. 1384315316 20:01:56 foo green 3 3 12 6 2 0 0
  34. % curl 192.168.56.10:9200/_cat/shards | fgrep RELO
  35. wiki1 0 r RELOCATING 3014 31.1mb 192.168.56.20 Commander Kraken -> 192.168.56.30 Frankie Raye
  36. wiki1 1 r RELOCATING 3013 29.6mb 192.168.56.10 Stiletto -> 192.168.56.30 Frankie Raye
  37. --------------------------------------------------
  38. [[states]]
  39. === Shard states
  40. Before a shard can be used, it goes through an `INITIALIZING` state.
  41. `shards` can show you which ones.
  42. [source,sh]
  43. --------------------------------------------------
  44. % curl -XPUT 192.168.56.20:9200/_settings -d'{"number_of_replicas":1}'
  45. {"acknowledged":true}
  46. % curl 192.168.56.20:9200/_cat/shards
  47. wiki1 0 p STARTED 3014 31.1mb 192.168.56.10 Stiletto
  48. wiki1 0 r INITIALIZING 0 14.3mb 192.168.56.30 Frankie Raye
  49. wiki1 1 p STARTED 3013 29.6mb 192.168.56.30 Frankie Raye
  50. wiki1 1 r INITIALIZING 0 13.1mb 192.168.56.20 Commander Kraken
  51. wiki1 2 r INITIALIZING 0 14mb 192.168.56.10 Stiletto
  52. wiki1 2 p STARTED 3973 38.1mb 192.168.56.20 Commander Kraken
  53. --------------------------------------------------
  54. If a shard cannot be assigned, for example you've overallocated the
  55. number of replicas for the number of nodes in the cluster, they will
  56. remain `UNASSIGNED`.
  57. [source,sh]
  58. --------------------------------------------------
  59. % curl -XPUT 192.168.56.20:9200/_settings -d'{"number_of_replicas":3}'
  60. % curl 192.168.56.20:9200/_cat/health
  61. 1384316325 20:18:45 foo yellow 3 3 9 3 0 0 3
  62. % curl 192.168.56.20:9200/_cat/shards
  63. wiki1 0 p STARTED 3014 31.1mb 192.168.56.10 Stiletto
  64. wiki1 0 r STARTED 3014 31.1mb 192.168.56.30 Frankie Raye
  65. wiki1 0 r STARTED 3014 31.1mb 192.168.56.20 Commander Kraken
  66. wiki1 0 r UNASSIGNED
  67. wiki1 1 r STARTED 3013 29.6mb 192.168.56.10 Stiletto
  68. wiki1 1 p STARTED 3013 29.6mb 192.168.56.30 Frankie Raye
  69. wiki1 1 r STARTED 3013 29.6mb 192.168.56.20 Commander Kraken
  70. wiki1 1 r UNASSIGNED
  71. wiki1 2 r STARTED 3973 38.1mb 192.168.56.10 Stiletto
  72. wiki1 2 r STARTED 3973 38.1mb 192.168.56.30 Frankie Raye
  73. wiki1 2 p STARTED 3973 38.1mb 192.168.56.20 Commander Kraken
  74. wiki1 2 r UNASSIGNED
  75. --------------------------------------------------