elasticsearch 7处于黄色状态,具有未分配的碎片

i34xakig  于 2022-12-26  发布在  ElasticSearch
关注(0)|答案(1)|浏览(392)

我无法获取处于绿色工作状态的单个主节点的群集:ElasticSearch:7.17.0
我想这是因为我有unassigned_shards〉0

配置:

apiVersion: v1
data:
  elasticsearch.yml: |-
    discovery:
      type: single-node
    network:
      host: 0.0.0.0
    path:
      data: /bitnami/elasticsearch/data
    xpack:
      ml:
        enabled: false
kind: ConfigMap
metadata:
  labels:
    app.kubernetes.io/instance: elasticsearch
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: elasticsearch
    argocd.argoproj.io/instance: elasticsearch
    helm.sh/chart: elasticsearch-19.5.5
  name: elasticsearch
  namespace: elasticsearch
kubectl logs elasticsearch-master-0

[2022-12-25T07:52:40,652][INFO ][o.e.c.r.a.AllocationService] [elasticsearch-master-0] Cluster health status changed from [RED] to [YELLOW] (reason: [shards started [[.ds-ilm-history-5-2022.10.28-000014][0], [.ds-ilm-history-5-2022.09.28-000012][0]]]).
[2022-12-25T07:52:40,856][INFO ][o.e.i.g.GeoIpDownloader  ] [elasticsearch-master-0] updating geoip database [GeoLite2-ASN.mmdb]

✗  curl -XGET http://localhost:9200/_cluster/health\?pretty\=true
{
  "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" : 1,
  "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" : 87.5
}

➜ curl -XGET http://localhost:9200/_cat/shards                                                                                         
magento2_product_1_v583                                       0 p STARTED    4868 18.9mb 10.110.4.229 elasticsearch-master-0
.ds-ilm-history-5-2022.10.28-000014                           0 p STARTED                10.110.4.229 elasticsearch-master-0
.ds-ilm-history-5-2022.11.27-000015                           0 p STARTED                10.110.4.229 elasticsearch-master-0
.ds-ilm-history-5-2022.08.29-000010                           0 p STARTED                10.110.4.229 elasticsearch-master-0
.ds-ilm-history-5-2022.09.28-000012                           0 p STARTED                10.110.4.229 elasticsearch-master-0
.geoip_databases                                              0 p STARTED      40 38.1mb 10.110.4.229 elasticsearch-master-0
.ds-.logs-deprecation.elasticsearch-default-2022.12.21-000022 0 p STARTED                10.110.4.229 elasticsearch-master-0
.ds-.logs-deprecation.elasticsearch-default-2022.12.21-000022 0 r UNASSIGNED

我正在尝试删除它,但遇到错误

➜ curl -XGET http://localhost:9200/_cat/shards | grep UNASSIGNED | awk {'print $1'} | xargs -i curl -XDELETE "http://localhost:9200/{}"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   986  100   986    0     0   5241      0 --:--:-- --:--:-- --:--:--  5244
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"index [.ds-.logs-deprecation.elasticsearch-default-2022.12.21-000022] is the write index for data stream [.logs-deprecation.elasticsearch-default] and cannot be deleted"}],"type":"illegal_argument_exception","reason":"index [.ds-.logs-deprecation.elasticsearch-default-2022.12.21-000022] is the write index for data stream [.logs-deprecation.elasticsearch-default] and cannot be deleted"},"status":400}
    • GET/_群集/分配/解释**:
➜ curl -XGET http://localhost:9200/_cluster/allocation/explain\?pretty\=true | jq
{
  "note": "No shard was specified in the explain API request, so this response explains a randomly chosen unassigned shard. There may be other unassigned shards in this cluster which cannot be assigned for different reasons. It may not be possible to assign this shard until one of the other shards is assigned correctly. To explain the allocation of other shards (whether assigned or unassigned) you must specify the target shard in the request to this API.",
  "index": ".ds-.logs-deprecation.elasticsearch-default-2022.12.21-000022",
  "shard": 0,
  "primary": false,
  "current_state": "unassigned",
  "unassigned_info": {
    "reason": "CLUSTER_RECOVERED",
    "at": "2022-12-25T07:52:37.022Z",
    "last_allocation_status": "no_attempt"
  },
  "can_allocate": "no",
  "allocate_explanation": "cannot allocate because allocation is not permitted to any of the nodes",
  "node_allocation_decisions": [
    {
      "node_id": "aURccTcnSuqPC3fBfmezCg",
      "node_name": "elasticsearch-master-0",
      "transport_address": "10.110.4.229:9300",
      "node_attributes": {
        "xpack.installed": "true",
        "transform.node": "true"
      },
      "node_decision": "no",
      "deciders": [
        {
          "decider": "same_shard",
          "decision": "NO",
          "explanation": "a copy of this shard is already allocated to this node [[.ds-.logs-deprecation.elasticsearch-default-2022.12.21-000022][0], node[aURccTcnSuqPC3fBfmezCg], [P], s[STARTED], a[id=tsxhnODlSn-i__-vEvJj3A]]"
        }
      ]
    }
  ]

那么在这种情况下可以做些什么呢?

curl -v -XPUT "localhost:9200/*/_settings" -H 'Content-Type: application/json' -d '
{
  "index" : {
    "number_of_replicas" : 0
  }
}
'

{"acknowledged":true}

curl -XGET http://localhost:9200/_cat/indices     
green open magento2_product_1_v583 hvYpUxJUT16-g6_YS8qkaA 1 0 4868  0 18.9mb 18.9mb
green open .geoip_databases        tDXBLQRdSFeQyi6Pk5zq2Q 1 0   40 40 38.1mb 38.1mb
gorkyyrv

gorkyyrv1#

黄色状态表示Elasticsearch群集上的一个或多个副本碎片未分配给节点。当您只有一个节点时,这意味着您的副本数量大于您的节点数量。Elasticsearch永远不会将副本分配给与主碎片相同的节点。因此,如果您只有一个节点,则群集显示黄色是完全正常的,也是意料之中的。但是,如果你不相信并且希望你的集群是绿色的,那么将每个索引的副本数量设置为0。

PUT /my-index/_settings
{
    "index" : {
        "number_of_replicas" : 0
    }
}

相关问题