索引yellow 分片 UNASSIGNED 解决方案1

  • 环境 ElasticSearch5.x

产生unassigned shards的原因

只有一台机器,跑了es,但是你却在index中的settings中设置了replica为1,显然这个replica shard就会成为unassigned shards
而且你在查看原因的时候,其会显示
the shard cannot be allocated to the same node on which a copy of the shard already exists
即分片不能分配到已经存在分片副本的同一节点

如何解决

  1. GET /_cat/shards/dbaudit-2020.08.19?v&format=json&pretty
[
  {
    "index": "dbaudit-2020.08.19",
    "shard": "1",
    "prirep": "p",
    "state": "STARTED",
    "docs": "690",
    "store": "170.8kb",
    "ip": "10.47.211.100",
    "node": "node-1"
  },
  {
    "index": "dbaudit-2020.08.19",
    "shard": "1",
    "prirep": "r",
    "state": "UNASSIGNED",
    "docs": null,
    "store": null,
    "ip": null,
    "node": null
  },
  {
    "index": "dbaudit-2020.08.19",
    "shard": "2",
    "prirep": "p",
    "state": "STARTED",
    "docs": "729",
    "store": "169.7kb",
    "ip": "10.47.211.100",
    "node": "node-1"
  },
  {
    "index": "dbaudit-2020.08.19",
    "shard": "2",
    "prirep": "r",
    "state": "UNASSIGNED",
    "docs": null,
    "store": null,
    "ip": null,
    "node": null
  },
  {
    "index": "dbaudit-2020.08.19",
    "shard": "0",
    "prirep": "p",
    "state": "STARTED",
    "docs": "668",
    "store": "160.5kb",
    "ip": "10.47.211.100",
    "node": "node-1"
  },
  {
    "index": "dbaudit-2020.08.19",
    "shard": "0",
    "prirep": "r",
    "state": "UNASSIGNED",
    "docs": null,
    "store": null,
    "ip": null,
    "node": null
  }
]
  1. 把副本分片设置为0
PUT /dbaudit-2020.07.19/_settings
{
  "number_of_replicas": 0
}

参考

如何处理elastic search中的unassigned shards?
How to resolve unassigned shards in Elasticsearch

posted @ 2020-08-21 16:30  zendwang  阅读(899)  评论(0编辑  收藏  举报