首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >ES 分片未分配处理

ES 分片未分配处理

原创
作者头像
周银辉
修改2025-01-15 15:36:42
修改2025-01-15 15:36:42
2240
举报

定位到未分配的索引

一、确定你所知道的主要问题。

1、超过磁盘水位线设置,85%,90%,95%

85%:新分片不再分配到节点。

90%:移动一部分分片到其它节点。

95%:索引被标识为只读。

检查方法:

GET /_cat/nodes?v

GET /_cat/allocation?v

解决方案:

1、取消部分索引的副本分片。

2、移动分片重新分配分片。

3、临时调整水位

代码语言:txt
复制
PUT _cluster/settings
{
  "persistent": {
    "cluster.routing.allocation.disk.watermark.low": "85%",
    "cluster.routing.allocation.disk.watermark.high": "90%",
    "cluster.routing.allocation.disk.watermark.flood_stage": "95%"
  }
}

3、每个节点最大数设置

代码语言:txt
复制
GET /_cluster/settings?include_defaults&flat_settings
PUT /_cluster/settings
{
  "transient": {
    "cluster.max_shards_per_node":"1200"
  }
}

确定是哪些索引和哪些索引的分片,什么原因

代码语言:txt
复制
GET _cat/indices?v&health=yellow
GET _cat/shards/tms_waybill_xxx?v
PUT _cluster/settings
{
  "transient": {
    "cluster.routing.allocation.enable":"all"
  }
}
GET _cluster/allocation/explain?pretty

分配索引

代码语言:txt
复制
修复分片
POST _cluster/reroute?retry_failed=true
GET /_cat/indices?v&health=red
GET /_cat/shards?v&h=n,index,shard,prirep,state,sto,sc,unassigned.reason,unassigned.details&s=sto,index
GET /_cluster/allocation/explain
{
  "index":"crm_express_month_201901",
  "shard":"1",
  "primary":true
}

POST /_cluster/reroute
{
  "commands": [
    {
      "move": {
        "index": "test", "shard": 0,
        "from_node": "node1", "to_node": "node2"
      }
    },
    {
      "allocate_replica": {
        "index": "test", "shard": 1,
        "node": "node3"
      }
    },
	{
      "allocate_stale_primary": {
        "index": "<index_name>",
        "shard": <shard_id>,
        "node": "<node_name>",
        "accept_data_loss": true
      }
    }
  ]
}

POST localhost:9200/twitter/_close?pretty
{
  "acknowledged": true
}
POST localhost:9200/twitter/_open?pretty
{
  "acknowledged": true,
  "shards_acknowledged": true
}

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 定位到未分配的索引
    • 一、确定你所知道的主要问题。
    • 确定是哪些索引和哪些索引的分片,什么原因
    • 分配索引
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档