ES 副本分片UNASSIGNED

一直看ES的集羣狀態都是yellow,一開始沒在乎,後來越覺奇怪,三個節點,5個主片5個副片,node-3上一直沒分片,主片分在了node-1,node-2,副片分在。。。node

 

啊,副片全都UNASSIGNED了,才發現。。。。。。。curl

因而乎進行rerouterui

首先貓一下分片狀況url

>>> curl -XGET 'http://localhost:9200/_cat/shards'spa

my_index 4 p STARTED    104917 157.2mb 127.0.0.1 node-1
my_index 4 r UNASSIGNED
my_index 3 p STARTED    104892 156.7mb 127.0.0.1 node-1
my_index 3 r UNASSIGNED
my_index 2 p STARTED    104714 155.6mb 127.0.0.1 node-1
my_index 2 r UNASSIGNED
my_index 1 p STARTED    104874 156.5mb 127.0.0.1 node-2
my_index 1 r UNASSIGNED
my_index 0 p STARTED    105933 156.5mb 127.0.0.1 node-1
my_index 0 r UNASSIGNED.net

 

0-4  5個r分片全淪陷了(head上就看出來了好伐...)router

而後進行rerouteblog

curl -XPOST 'localhost:9200/_cluster/reroute' -d '{
        "commands" : [ {
              "allocate" : {
                  "index" : "my_index",
                  "shard" : 這裏是分片,
                  "node" : 這裏是節點,
                  "allow_primary" : true
              }
            }
        ]
    }'get

爲了方便寫個腳本去作博客

#!bin/sh
for index in $(curl -s 'http://localhost:9200/_cat/shards' | grep UNASSIGNED | awk '{print $1}' | sort | uniq); do
    for shard in $(curl -s 'http://localhost:9200/_cat/shards' | grep UNASSIGNED | grep $index | awk '{print $2}' | sort | uniq); do
        echo $index $shard
        curl -XPOST 'http://localhost:9200/_cluster/reroute' -d "{'commands':[{'allocate':{'index':$index,'shard':$shard,'node':'node-3','allow_primary':true}}]}"
        sleep 5
    done
done

 

好,試一下。。。。。。。果斷報錯

  • "type": "illegal_argument_exception",
  • "reason": "[allocate] allocation of [my_index][0] on node {node-3}{rjG_j423SpejhzmAAUCcqA}{127.0.0.1}{127.0.0.1:9320} is not allowed, reason: [NO(more than allowed [85.0%] used disk on node, free: [6.234234497791846%])][YES(node passes include/exclude/require filters)][YES(allocation disabling is ignored)][YES(shard is not allocated to same node or host)][YES(target node version [2.4.4] is same or newer than source node version [2.4.4])][YES(shard not primary or relocation disabled)][YES(below shard recovery limit of [2])][YES(total shard limit disabled: [index: -1, cluster: -1] <= 0)][YES(primary is already active)][YES(allocation disabling is ignored)][YES(no allocation awareness enabled)]"

這個。。。眼睛有點兒花。直接去查查reroute失敗的緣由,瞄到以下信息(來自博客http://blog.csdn.net/xiangcheng001/article/details/51133364)

 

啊,貌似在錯誤裏看到了個85,回看眼錯誤信息是有個相關的描述。

df -h 檢查一下

乖乖,啥時候這麼多了。

嗯,再見了,我心愛的電影,大電影,小電影

刪完以後再reroute,

{

  • "acknowledged": true,
  • "state": {
    • "version": 17,
    • "state_uuid": "WrYBhVr5T7aem4uReXaRCA",
    • "master_node": "6gDDoI_OS32VjAxmCGTSsg",
    • "blocks": { },
    • "nodes": {
      • "71GSL-osQeaLv-cDU9bygA": {
        • "name": "node-2",
        • "transport_address": "127.0.0.1:9310",
        • "attributes": { }
        },
      • "6gDDoI_OS32VjAxmCGTSsg": {
        • "name": "node-1",
        • "transport_address": "127.0.0.1:9300",
        • "attributes": { }
        },
      • "rjG_j423SpejhzmAAUCcqA": {
        • "name": "node-3",
        • "transport_address": "127.0.0.1:9320",
        • "attributes": { }
        }
      },
    • "routing_table": {
      • "indices": {
        • "enterprise_data_gov_20170324": {
          • "shards": {
            • "0": [
              • {
                • "state": "STARTED",
                • "primary": true,
                • "node": "6gDDoI_OS32VjAxmCGTSsg",
                • "relocating_node": null,
                • "shard": 0,

balabala的

 

後來發現其實不用rerouter就已經自動修復了,

好,你們都綠的發亮了,皆大歡喜

相關文章
相關標籤/搜索