ElasticSearch单机健康状况为黄色的处理方法

本文展示了如何通过curl命令检查Elasticsearch集群的健康状态,从黄色状态到绿色状态的过程,调整副本 shards 数量以优化性能。过程中涉及到了索引的设置、shards 的分配与健康状况,以及最终达到的全绿状态。

# curl http://localhost:9200/_cluster/health?pretty
{
  "cluster_name" : "elasticsearch",
  "status" : "yellow",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 37,
  "active_shards" : 37,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 26,
  "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" : 58.730158730158735
}

# curl -X GET 'http://localhost:9200/_cat/indices'?v
health status index                          uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   logstash-2020.09.10            jlCbWlHySveGntTs-DG2eA   1   1  179057269            0     35.1gb         35.1gb
yellow open   logstash-2020.09.11            rty9vwTBS3OxH1evu1Kc9g   1   1  172997561            0     32.5gb         32.5gb
......

# curl -X GET 'http://localhost:9200/_settings'?pretty=true
{
  "logstash-2020.09.07" : {
    "settings" : {
      "index" : {
        "refresh_interval" : "5s",
        "number_of_shards" : "1",
        "provided_name" : "logstash-2020.09.07",
        "creation_date" : "1599436800757",
        "number_of_replicas" : "1",
        "uuid" : "W-7zp7R8Q7OF78pezzFpig",
        "version" : {
          "created" : "7080099"
        }
      }
    }
  },
  "logstash-2020.09.12" : {
    "settings" : {
      "index" : {
        "refresh_interval" : "5s",
        "number_of_shards" : "1",
        "provided_name" : "logstash-2020.09.12",
        "creation_date" : "1599869321680",
        "number_of_replicas" : "1",
        "uuid" : "OjwNHjCZSp6a-2vmNkDl3g",
        "version" : {
          "created" : "7080099"
        }
      }
    }
  },
......


curl -XPUT --header 'Content-Type: application/json' http://localhost:9200/_settings -d '{"number_of_replicas" : "0"}'

#  curl http://localhost:9200/_cluster/health?pretty
{
  "cluster_name" : "elasticsearch",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 37,
  "active_shards" : 37,
  "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
}

# curl -X GET 'http://localhost:9200/_cat/indices'?v
health status index                          uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   logstash-2020.09.10            jlCbWlHySveGntTs-DG2eA   1   0  179057269            0     35.1gb         35.1gb
green  open   logstash-2020.09.11            rty9vwTBS3OxH1evu1Kc9g   1   0  172997561            0     32.5gb         32.5gb

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值