Elasticsearch恢复后索引仍为红色。怎么把它变成绿色?

时间:2016-02-05 13:57:31

标签: elasticsearch

我正在使用ES 2.2

使用

恢复索引后
POST /_snapshot/s3_repository/snapshot_traces_291215/_restore
{
    "include_global_state": false
}

我的索引仍为红色red open traces_v2 3 1

以下是群集运行状况:

{
   "cluster_name": "burst",
   "status": "red",
   "timed_out": false,
   "number_of_nodes": 1,
   "number_of_data_nodes": 1,
   "active_primary_shards": 0,
   "active_shards": 0,
   "relocating_shards": 0,
   "initializing_shards": 0,
   "unassigned_shards": 6,
   "delayed_unassigned_shards": 0,
   "number_of_pending_tasks": 0,
   "number_of_in_flight_fetch": 0,
   "task_max_waiting_in_queue_millis": 0,
   "active_shards_percent_as_number": 0
}

我确信恢复已经完成。我用GET /_cat/recovery?v

检查了它

GET /_cat/_shards?v给了我:

index     shard prirep state      docs store ip node 
traces_v2 2     p      UNASSIGNED                    
traces_v2 2     r      UNASSIGNED                    
traces_v2 1     p      UNASSIGNED                    
traces_v2 1     r      UNASSIGNED                    
traces_v2 0     p      UNASSIGNED                    
traces_v2 0     r      UNASSIGNED  

2.1和ES 2.2的快照之间是否存在任何版本不兼容?

1 个答案:

答案 0 :(得分:0)

我强制将原色分片分配给我的节点。

GET _cluster/reroute
{
    "commands" : [ {
          "allocate" : {
              "index" : "traces_v2", 
              "shard" : "2", 
              "node" : "Killer Shrike", 
              "allow_primary" : true
          }
        }
    ]
}

但状态仍为黄色,因为我在单个节点上运行ES并且我有3个副本分片。副本分片无法在已有主分片的节点上运行。

所以我通过将索引的副本分片数设置为0来删除它们。

PUT /_settings
{
    "index" : {
        "number_of_replicas" : 0
    }
}

我希望这能帮助像我这样的其他菜鸟!