ElasticSearch6.8:未分配的分片

huangapple go评论62阅读模式
英文:

ElasticSearch6.8: Unassigned Shards

问题

My Elasticsearch 中一些分片未分配。
我使用以下命令来查找如下所示的问题。
未分配分片的原因是在副本节点上的 INDEX_CREATION,这是什么意思?
我的Elasticsearch在单台机器上运行,单节点集群。
我可以简单地删除这个未分配的分片吗?会导致数据丢失吗?
谢谢您提前。

curl -XGET localhost:9200/_cat/shards?h=index,shards,state,prirep,unassigned.reason | grep UNASSIGNED

使用 curl -XGET localhost:9200/_cluster/allocation/explain 的结果

{
  "index": "filebeat-6.8.22-xxx-2023.06.28",
  "shard": 2,
  "primary": false,
  "current_state": "unassigned",
  "unassigned_info": {
    "reason": "INDEX_CREATED",
    "at": "2023-06-27T22:30:57.674Z",
    "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": "Uhqplef-S3mJRdDIonSGPw",
      "node_name": "Uhqplef",
      "transport_address": "x.x.x.x:9300",
      "node_attributes": {
        "ml.machine_memory": "37665476608",
        "xpack.installed": "true",
        "ml.max_open_jobs": "20",
        "ml.enabled": "true"
      },
      "node_decision": "no",
      "weight_ranking": 1,
      "deciders": [
        {
          "decider": "same_shard",
          "decision": "NO",
          "explanation": "the shard cannot be allocated to the same node on which a copy of the shard already exists [[filebeat-6.8.22-xxx-2023.06.28][2], node[Uhqplef-S3mJRdDIonSGPw], [P], s[STARTED], a[id=Gh6Wxo0QROC_x68MNPq1TQ]]"
        }
      ]
    }
  ]
}
英文:

my elasticsearch has some unassigned shards.
I used below command to find it as below shown
The reason for unassigned shard is INDEX_CREATION at replica node, what doe it mean?
my elasticsearch is running on single machine , single node cluster.
Could I just simply delete this unassigned shard? will it be data loss problem?

thank you in advance

curl -XGET localhost:9200/_cat/shards?h=index,shards,state,prirep,unassigned.reason | grep UNASSIGNED
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 31005  100 31005    0     0  1081k     filebeat-6.8.22-<MY_APP_NAME>-2023.06.28                    UNASSIGNED r INDEX_CREATED

result with curl -XGET localhost:9200/_cluster/allocation/explain

{
  "index": "filebeat-6.8.22-xxx-2023.06.28",
  "shard": 2,
  "primary": false,
  "current_state": "unassigned",
  "unassigned_info": {
    "reason": "INDEX_CREATED",
    "at": "2023-06-27T22:30:57.674Z",
    "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": "Uhqplef-S3mJRdDIonSGPw",
      "node_name": "Uhqplef",
      "transport_address": "x.x.x.x:9300",
      "node_attributes": {
        "ml.machine_memory": "37665476608",
        "xpack.installed": "true",
        "ml.max_open_jobs": "20",
        "ml.enabled": "true"
      },
      "node_decision": "no",
      "weight_ranking": 1,
      "deciders": [
        {
          "decider": "same_shard",
          "decision": "NO",
          "explanation": "the shard cannot be allocated to the same node on which a copy of the shard already exists [[filebeat-6.8.22-xxx-2023.06.28][2], node[Uhqplef-S3mJRdDIonSGPw], [P], s[STARTED], a[id=Gh6Wxo0QROC_x68MNPq1TQ]]"
        }
      ]
    }
  ]
}

答案1

得分: 1

由于您只有一个数据节点,并且您的索引具有主分片和副本分片,副本不能分配给任何节点作为主分片,也不能分配给同一节点作为副本分片。

您可以像这样简单地删除副本:

PUT filebeat-*/_settings
{
  "index.number_of_replicas": 0
}

如果您对Filebeat索引有索引模板,您还可以在索引模板中进行修改,以便新的索引创建时不包含副本分片。

英文:

Since you have a single data node and your index has a primary and a replica shard, the replica cannot be allocated to any node as a primary and replica shard cannot be allocated to the same node.

You can simply remove the replica like this:

PUT filebeat-*/_settings
{
  "index.number_of_replicas": 0
}

If you have an index template for your filebeat indexes, you can also make the modification in the index template so that new indexes are created without replica shard.

huangapple
  • 本文由 发表于 2023年6月29日 14:37:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76578579.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定