This topic describes how to perform online operation and maintenance (O&M). You can use the online O&M feature to monitor the status of your Alibaba Cloud Elasticsearch cluster and mitigate potential risks.

Prerequisites

An Elasticsearch cluster is created. For more information, see Create an Elasticsearch cluster.

View the health status of an Elasticsearch cluster

  1. Log on to the Kibana console of your Elasticsearch cluster.
    For more information, see Log on to the Kibana console.
  2. In the left-side navigation pane, click Dev Tools.
  3. On the Console tab, run the following command to query the health status of your Elasticsearch cluster:
    GET /_cluster/health
    If the operation is successful, the following result is returned:
    {
      "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
    }
    The status parameter indicates the health status of the Elasticsearch cluster. The valid values are green, yellow, and red.
    Value State Description
    red Not all of the shards are available. One or more indexes have unassigned shards.
    yellow All shards are available, but not all of the replicas are available. One or more indexes have unassigned replicas.
    green All shards and replicas are available. All indexes in the cluster are healthy. No unassigned shards or replicas exist.
    Notice If the status value of your Elasticsearch cluster is yellow, operations on the Elasticsearch cluster require a longer time to complete. These operations include the password change and cluster configuration upgrade. If the status value of your cluster is not green, we recommend that you recover indexes before you perform other operations. If an index in a cluster has unassigned replicas, the status value of your cluster is yellow. In this case, you must locate the index and recover it. For more information, see FAQ.

FAQ

Question: My Elasticsearch cluster is in the yellow state. What can I do to solve this issue?

Answer: If an index in your cluster has unassigned replicas, the cluster is in the yellow state. You must perform the following operations to locate the index and recover it:
  1. Query the status of all indexes.
    curl -u <Username>:<Password> http://<host>:9200/_cat/indices                   
    The index that is in the yellow state is the one that has unassigned replicas.Index that has unassigned replicas
  2. Recover the index.
    curl -XPUT -u <Username>:<Password> http://<host>:9200/<Index that has unassigned replicas>/_settings -H 'Content-Type: application/json' -d '{"index":{"number_of_replicas":(<Number of nodes - 1>)}'              

    If the number of replicas that you specify for the index is greater than the number of nodes minus 1, the cluster is in the yellow state. You can run this command to adjust the number of replicas.

    For example, the cluster has three nodes and one or more indexes have three replicas. In this case, the cluster is in the yellow state. To solve this issue, set the number of replicas to 2 for these indexes.

    Notice After you restart, scale out, or customize the configuration of your Elasticsearch cluster, set the number of replicas to a suitable value according to the number of nodes. This improves the reliability and stability of your Elasticsearch cluster.