English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
L'API del cluster viene utilizzata per ottenere informazioni sul cluster e sui nodi e per apportare modifiche. Per chiamare questa API, dobbiamo specificare il nome del nodo, l'indirizzo o _local.
GET /_nodes/_local
Eseguito il codice sopra, otteniamo la risposta seguente:
……………………………………………… cluster_name": "elasticsearch", "nodes" : { "FKH-5blYTJmff2rJ_lQOCg" : { "name" : "ubuntu", "transport_address" : "127.0.0.1:9300", "host" : "127.0.0.1", "ip": "127.0.0.1", "version": "7.0.0", "build_flavor": "default", "build_type": "tar", "build_hash": "b7e28a7", "total_indexing_buffer": 106502553, "roles" : [ "master", "data", "ingest" ], "attributes" : { ………………………………………………
L'API viene utilizzata per ottenere lo stato di funzionamento del cluster aggiungendo la parola chiave 'health'.
GET /_cluster/health
Eseguito il codice sopra, otteniamo la risposta seguente:
{ "cluster_name" : "elasticsearch", "status": "yellow", "timed_out": false, "number_of_nodes": 1, "number_of_data_nodes": 1, "active_primary_shards": 7, "active_shards": 7, "relocating_shards": 0, "initializing_shards": 0, "unassigned_shards": 4, "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": 63.63636363636363 }
L'API viene utilizzata per ottenere informazioni sullo stato del cluster aggiungendo la parola chiave 'state' all'URL. Le informazioni di stato includono versione, nodo principale, altri nodi, tabella di routing, metadati e blocchi.
GET /_cluster/state
Eseguito il codice sopra, otteniamo la risposta seguente:
……………………………………………… { "cluster_name" : "elasticsearch", "cluster_uuid": "IzKu0OoVTQ6LxqONJnN2eQ", "version": 89, "state_uuid": "y3BlwvspR1eUQBTo0aBjig", "master_node": "FKH-5blYTJmff2rJ_lQOCg", "blocks": {}, "nodes" : { "FKH-5blYTJmff2rJ_lQOCg" : { "name" : "ubuntu", "ephemeral_id": "426kTGpITGixhEzaM-5Qyg", "transport" } ………………………………………………
L'API utilizza la parola chiave 'stats' per aiutare a recuperare informazioni statistiche sul cluster. L'API restituisce il numero di shard, la dimensione di archiviazione, l'uso della memoria, il numero di nodi, il ruolo, il sistema operativo e il file system.
GET /_cluster/stats
Eseguito il codice sopra, otteniamo la risposta seguente:
…………………………………………. "cluster_name" : "elasticsearch", "cluster_uuid": "IzKu0OoVTQ6LxqONJnN2eQ", "timestamp": 1556435464704, "status": "yellow", "indices": { "count": 7, "shards" : { "total": 7, "primaries": 7, "replication": 0.0, "index" : {}} "shards" : { "min" : 1, "max" : 1, "avg" : 1.0 }, "primaries" : { "min" : 1, "max" : 1, "avg" : 1.0 }, "replication" : { "min" : 0.0, "max" : 0.0, "avg" : 0.0 } ………………………………………….
Utilizzando questa API, puoi aggiornare le impostazioni del cluster utilizzando la parola chiave "set". Ci sono due tipi di impostazioni - persistenti (applicate durante il riavvio) e transitorie (non sopravvivono a un riavvio completo del cluster).
Questa API viene utilizzata per recuperare informazioni statistiche su un altro nodo del cluster. Le informazioni statistiche del nodo sono quasi identiche a quelle del cluster.
GET /_nodes/stats
Eseguito il codice sopra, otteniamo la risposta seguente:
{ "_nodes" : { "total" : 1, "successful" : 1, "failed" : 0 }, "cluster_name" : "elasticsearch", "nodes" : { "FKH-5blYTJmff2rJ_lQOCg" : { "timestamp" : 1556437348653, "name" : "ubuntu", "transport_address" : "127.0.0.1:9300", "host" : "127.0.0.1", "ip" : "127.0.0.1:9300", "roles" : [ "master", "data", "ingest" ], "attributes" : { "ml.machine_memory" : "4112797696" "xpack.installed" : "true", "ml.max_open_jobs" : "20" }, ………………………………………………………….
Questa API può aiutarti a recuperare informazioni sui thread attivi attualmente su ogni nodo del cluster.
GET /_nodes/hot_threads
Eseguito il codice sopra, otteniamo la risposta seguente:
:::{ubuntu}{FKH-5blYTJmff2rJ_lQOCg}{426kTGpITGixhEzaM5Qyg}{127.0.0.1}{127.0.0.1:9300}{ml.machine_memory=4112797696,} xpack.installed=true, ml.max_open_jobs=20 Hot threads at 2019-04-28T07:43:58.265Z, interval=500ms, busiestThreads=3, ignoreIdleThreads=true: