|
@@ -5,15 +5,26 @@ The `shards` command is the detailed view of what nodes contain which
|
|
|
shards. It will tell you if it's a primary or replica, the number of
|
|
|
docs, the bytes it takes on disk, and the node where it's located.
|
|
|
|
|
|
-Here we see a single index, with three primary shards and no replicas:
|
|
|
-
|
|
|
-[source,sh]
|
|
|
---------------------------------------------------
|
|
|
-% curl 192.168.56.20:9200/_cat/shards
|
|
|
-wiki1 0 p STARTED 3014 31.1mb 192.168.56.10 H5dfFeA
|
|
|
-wiki1 1 p STARTED 3013 29.6mb 192.168.56.30 bGG90GE
|
|
|
-wiki1 2 p STARTED 3973 38.1mb 192.168.56.20 I8hydUG
|
|
|
---------------------------------------------------
|
|
|
+Here we see a single index, with one primary shard and no replicas:
|
|
|
+
|
|
|
+[source,js]
|
|
|
+---------------------------------------------------------------------------
|
|
|
+GET _cat/shards
|
|
|
+---------------------------------------------------------------------------
|
|
|
+// CONSOLE
|
|
|
+// TEST[setup:twitter]
|
|
|
+
|
|
|
+This will return
|
|
|
+
|
|
|
+[source,js]
|
|
|
+---------------------------------------------------------------------------
|
|
|
+twitter 0 p STARTED 3014 31.1mb 192.168.56.10 H5dfFeA
|
|
|
+---------------------------------------------------------------------------
|
|
|
+// TESTRESPONSE[s/3014/\\d+/]
|
|
|
+// TESTRESPONSE[s/31.1/\\d+\.\\d+/]
|
|
|
+// TESTRESPONSE[s/mb/.*/]
|
|
|
+// TESTRESPONSE[s/192.168.56.10/.*/]
|
|
|
+// TESTRESPONSE[s/H5dfFeA/node-0/ _cat]
|
|
|
|
|
|
[float]
|
|
|
[[index-pattern]]
|
|
@@ -23,30 +34,47 @@ If you have many shards, you may wish to limit which indices show up
|
|
|
in the output. You can always do this with `grep`, but you can save
|
|
|
some bandwidth by supplying an index pattern to the end.
|
|
|
|
|
|
-[source,sh]
|
|
|
---------------------------------------------------
|
|
|
-% curl 192.168.56.20:9200/_cat/shards/wiki*
|
|
|
-wiki2 0 p STARTED 197 3.2mb 192.168.56.10 H5dfFeA
|
|
|
-wiki2 1 p STARTED 205 5.9mb 192.168.56.30 bGG90GE
|
|
|
-wiki2 2 p STARTED 275 7.8mb 192.168.56.20 I8hydUG
|
|
|
---------------------------------------------------
|
|
|
+[source,js]
|
|
|
+---------------------------------------------------------------------------
|
|
|
+GET _cat/shards/twitt*
|
|
|
+---------------------------------------------------------------------------
|
|
|
+// CONSOLE
|
|
|
+// TEST[setup:twitter]
|
|
|
+
|
|
|
+Which will return the following
|
|
|
+
|
|
|
+[source,js]
|
|
|
+---------------------------------------------------------------------------
|
|
|
+twitter 0 p STARTED 3014 31.1mb 192.168.56.10 H5dfFeA
|
|
|
+---------------------------------------------------------------------------
|
|
|
+// TESTRESPONSE[s/3014/\\d+/]
|
|
|
+// TESTRESPONSE[s/31.1/\\d+\.\\d+/]
|
|
|
+// TESTRESPONSE[s/mb/.*/]
|
|
|
+// TESTRESPONSE[s/192.168.56.10/.*/]
|
|
|
+// TESTRESPONSE[s/H5dfFeA/node-0/ _cat]
|
|
|
|
|
|
|
|
|
[float]
|
|
|
[[relocation]]
|
|
|
=== Relocation
|
|
|
|
|
|
-Let's say you've checked your health and you see two relocating
|
|
|
+Let's say you've checked your health and you see a relocating
|
|
|
shards. Where are they from and where are they going?
|
|
|
|
|
|
-[source,sh]
|
|
|
---------------------------------------------------
|
|
|
-% curl 192.168.56.10:9200/_cat/health
|
|
|
-1384315316 20:01:56 foo green 3 3 12 6 2 0 0
|
|
|
-% curl 192.168.56.10:9200/_cat/shards | fgrep RELO
|
|
|
-wiki1 0 r RELOCATING 3014 31.1mb 192.168.56.20 I8hydUG -> 192.168.56.30 bGG90GE
|
|
|
-wiki1 1 r RELOCATING 3013 29.6mb 192.168.56.10 H5dfFeA -> 192.168.56.30 bGG90GE
|
|
|
---------------------------------------------------
|
|
|
+[source,js]
|
|
|
+---------------------------------------------------------------------------
|
|
|
+GET _cat/shards
|
|
|
+---------------------------------------------------------------------------
|
|
|
+// CONSOLE
|
|
|
+// TEST[skip:for now, relocation cannot be recreated]
|
|
|
+
|
|
|
+A relocating shard will be shown as follows
|
|
|
+
|
|
|
+[source,js]
|
|
|
+---------------------------------------------------------------------------
|
|
|
+twitter 0 p RELOCATING 3014 31.1mb 192.168.56.10 H5dfFeA -> -> 192.168.56.30 bGG90GE
|
|
|
+---------------------------------------------------------------------------
|
|
|
+// TESTRESPONSE[_cat]
|
|
|
|
|
|
[float]
|
|
|
[[states]]
|
|
@@ -55,42 +83,45 @@ wiki1 1 r RELOCATING 3013 29.6mb 192.168.56.10 H5dfFeA -> 192.168.56.30 bGG90GE
|
|
|
Before a shard can be used, it goes through an `INITIALIZING` state.
|
|
|
`shards` can show you which ones.
|
|
|
|
|
|
-[source,sh]
|
|
|
---------------------------------------------------
|
|
|
-% curl -XPUT 192.168.56.20:9200/_settings -d'{"number_of_replicas":1}'
|
|
|
-{"acknowledged":true}
|
|
|
-% curl 192.168.56.20:9200/_cat/shards
|
|
|
-wiki1 0 p STARTED 3014 31.1mb 192.168.56.10 H5dfFeA
|
|
|
-wiki1 0 r INITIALIZING 0 14.3mb 192.168.56.30 bGG90GE
|
|
|
-wiki1 1 p STARTED 3013 29.6mb 192.168.56.30 bGG90GE
|
|
|
-wiki1 1 r INITIALIZING 0 13.1mb 192.168.56.20 I8hydUG
|
|
|
-wiki1 2 r INITIALIZING 0 14mb 192.168.56.10 H5dfFeA
|
|
|
-wiki1 2 p STARTED 3973 38.1mb 192.168.56.20 I8hydUG
|
|
|
---------------------------------------------------
|
|
|
+[source,js]
|
|
|
+---------------------------------------------------------------------------
|
|
|
+GET _cat/shards
|
|
|
+---------------------------------------------------------------------------
|
|
|
+// CONSOLE
|
|
|
+// TEST[skip:there is no guarantee to test for shards in initializing state]
|
|
|
+
|
|
|
+You can the the initializing state in the response like this
|
|
|
+
|
|
|
+[source,js]
|
|
|
+---------------------------------------------------------------------------
|
|
|
+twitter 0 p STARTED 3014 31.1mb 192.168.56.10 H5dfFeA
|
|
|
+twitter 0 r INITIALIZING 0 14.3mb 192.168.56.30 bGG90GE
|
|
|
+---------------------------------------------------------------------------
|
|
|
+// TESTRESPONSE[_cat]
|
|
|
|
|
|
If a shard cannot be assigned, for example you've overallocated the
|
|
|
number of replicas for the number of nodes in the cluster, the shard
|
|
|
will remain `UNASSIGNED` with the <<reason-unassigned,reason code>> `ALLOCATION_FAILED`.
|
|
|
|
|
|
-[source,sh]
|
|
|
---------------------------------------------------
|
|
|
-% curl -XPUT 192.168.56.20:9200/_settings -d'{"number_of_replicas":3}'
|
|
|
-% curl 192.168.56.20:9200/_cat/health
|
|
|
-1384316325 20:18:45 foo yellow 3 3 9 3 0 0 3
|
|
|
-% curl 192.168.56.20:9200/_cat/shards
|
|
|
-wiki1 0 p STARTED 3014 31.1mb 192.168.56.10 H5dfFeA
|
|
|
-wiki1 0 r STARTED 3014 31.1mb 192.168.56.30 bGG90GE
|
|
|
-wiki1 0 r STARTED 3014 31.1mb 192.168.56.20 I8hydUG
|
|
|
-wiki1 0 r UNASSIGNED ALLOCATION_FAILED
|
|
|
-wiki1 1 r STARTED 3013 29.6mb 192.168.56.10 H5dfFeA
|
|
|
-wiki1 1 p STARTED 3013 29.6mb 192.168.56.30 bGG90GE
|
|
|
-wiki1 1 r STARTED 3013 29.6mb 192.168.56.20 I8hydUG
|
|
|
-wiki1 1 r UNASSIGNED ALLOCATION_FAILED
|
|
|
-wiki1 2 r STARTED 3973 38.1mb 192.168.56.10 H5dfFeA
|
|
|
-wiki1 2 r STARTED 3973 38.1mb 192.168.56.30 bGG90GE
|
|
|
-wiki1 2 p STARTED 3973 38.1mb 192.168.56.20 I8hydUG
|
|
|
-wiki1 2 r UNASSIGNED ALLOCATION_FAILED
|
|
|
---------------------------------------------------
|
|
|
+You can use the shards API to find out that reason.
|
|
|
+
|
|
|
+[source,js]
|
|
|
+---------------------------------------------------------------------------
|
|
|
+GET _cat/shards?h=index,shard,prirep,state,unassigned.reason
|
|
|
+---------------------------------------------------------------------------
|
|
|
+// CONSOLE
|
|
|
+// TEST[skip:for now]
|
|
|
+
|
|
|
+The reason for an unassigned shard will be listed as the last field
|
|
|
+
|
|
|
+[source,js]
|
|
|
+---------------------------------------------------------------------------
|
|
|
+twitter 0 p STARTED 3014 31.1mb 192.168.56.10 H5dfFeA
|
|
|
+twitter 0 r STARTED 3014 31.1mb 192.168.56.30 bGG90GE
|
|
|
+twitter 0 r STARTED 3014 31.1mb 192.168.56.20 I8hydUG
|
|
|
+twitter 0 r UNASSIGNED ALLOCATION_FAILED
|
|
|
+---------------------------------------------------------------------------
|
|
|
+// TESTRESPONSE[_cat]
|
|
|
|
|
|
[float]
|
|
|
[[reason-unassigned]]
|