Elasticsearch

Tips pour un remind des commandes pour ES

État de santé

curl -XGET http://localhost:9200/_cluster/health?pretty
{
  "cluster_name" : "es-01",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 3,
  "number_of_data_nodes" : 3,
  "active_primary_shards" : 860,
  "active_shards" : 1720,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}

Lister les nodes

curl -XGET -s 'http://localhost:9200/_cat/nodes?v=true'
ip        heap.percent ram.percent cpu load_1m load_5m load_15m node.role   master name
10.8.0.23           32          93   4    0.20    0.13     0.15 cdfhilmrstw -      es-01a
10.8.0.22           59          96   5    0.20    0.15     0.21 cdfhilmrstw *      es-01c
10.8.0.21           38          98   8    0.57    1.15     1.75 cdfhilmrstw -      es-01b

Pour avoir des infos plus détailler, utiliser la variable h exemple :

curl -XGET -s 'http://localhost:9200/_cat/nodes?v=true&h=name,disk.used'
name      disk.used
es-01c    78.6gb
es-01b    95.7gb
es-01a    44.6gb

Lister les indices

curl -XGET -s 'http://localhost:9200/_cat/indices?v=true'
health status index           uuid    pri rep  docs.count    docs.deleted store.size  pri.store.size
green  open   nom_du_shard    WJNfQ   1   1    7396392       469783       7.1gb       3.5gb
green  open   nom_du_shard    Mv92g   1   1    7389516       586872         7gb       3.5gb
green  open   nom_du_shard    LuVEQ   1   1    3639073       304440       3.6gb       1.7gb
[...]

Lister les shards

Globalement
curl -XGET -s 'http://localhost:9200/_cat/shards?v'
Un shard spécifique
curl -XGET -s 'http://localhost:9200/_cat/shards/nom_du_shard?v'
index        shard prirep state       docs  store ip        node
nom_du_shard 0     r      STARTED 57386203 33.8gb 10.8.0.22 es-01a
nom_du_shard 0     p      STARTED 57386203 33.8gb 10.8.0.23 es-01c

Re-route

Globalement
curl -XPOST -s http://localhost:9200/_cluster/reroute
Un shard spécifique vers un autre nœud
curl -XPOST -s http://localhost:9200/_cluster/reroute?metric=none -H 'Content-Type: application/json' -d '
{
  "commands": [
    {
      "move": {
        "index": "nom_du_shard", "shard": 0,
        "from_node": "es-01a", "to_node": "es-01b"
      }
    }
  ]
}'

Last modified: Wed Apr 9 14:52:02 2025