Run the Cluster health API to check whether your Alibaba Cloud Elasticsearch cluster is fully operational and identify any unassigned shards that need attention.
Prerequisites
Before you begin, ensure that you have:
-
An Elasticsearch cluster. For more information, see Create an Elasticsearch cluster.
Check cluster health
-
Log on to the Kibana console of your Elasticsearch cluster. For more information, see Log on to the Kibana console.
-
In the left-side navigation pane, click Dev Tools.
-
On the Console tab, run the following command:
GET /_cluster/healthA successful response looks similar to the following:
{ "cluster_name" : "es-cn-45xxxxxxxxxxxxk1q", "status" : "green", "timed_out" : false, "number_of_nodes" : 2, "number_of_data_nodes" : 2, "active_primary_shards" : 18, "active_shards" : 36, "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 } -
Check the
statusfield to determine cluster health. If the status isgreen, no action is needed. If the status isyelloworred, recover the affected indexes before performing other operations.Status Shard allocation Operational impact greenAll primary and replica shards are assigned Cluster is fully operational yellowAll primary shards are assigned, but one or more replica shards are unassigned Cluster is operational but not fully redundant. Operations such as password changes and cluster configuration upgrades take longer to complete redOne or more primary shards are unassigned Some data is unavailable
Recover a yellow cluster
A cluster enters yellow state when replica shards cannot be assigned — typically because the configured replica count exceeds the number of available nodes minus one. For example, if your cluster has three nodes and an index is configured with three replica shards per primary shard, the replica shards cannot all be assigned and the cluster becomes yellow.
Follow these steps to locate and fix the affected index.
-
Query the status of all indexes to identify which index has unassigned replica shards:
curl -u <username>:<password> http://<host>:9200/_cat/indicesIn the output, find the index with a
yellowstatus. That index has unassigned replica shards.
-
Reduce the replica count for the affected index so it does not exceed the number of nodes minus one:
curl -XPUT -u <username>:<password> http://<host>:9200/<index-name>/_settings -H 'Content-Type: application/json' -d '{"index":{"number_of_replicas":(<number-of-nodes - 1>)}'For example, if your cluster has three nodes, set
number_of_replicasto2.Replace the following placeholders:
Placeholder Description <username>Your Kibana username <password>Your Kibana password <host>The endpoint of your cluster <index-name>The name of the index with unassigned replica shards <number-of-nodes - 1>The number of data nodes in your cluster minus one
number_of_replicas to match the updated node count. Keeping the replica count in sync with your cluster size improves reliability and stability.