ES 分片未分配处理

2024-09-29 11:00:19 浏览数 (3)

定位到未分配的索引

代码语言: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
分配陈腐的分片
POST _cluster/reroute?pretty" -d '
{
  "commands": [
    {
      "allocate_stale_primary": {
      "index": "{索引名称}",
      "shard": "{分片ID}",
      "node": "{节点名称}",
      "accept_data_loss": true
      }
    }
  ]
}
POST "localhost:9200/_cluster/reroute?pretty" -d '
{
    "commands" : [
        {
          "allocate_empty_primary" : {
              "index" : "{索引名称}", 
              "shard" : "{分片ID}",
              "node" : "{节点名称}",
              "accept_data_loss": true
          }
        }
    ]
}'

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

0 人点赞