我的ElasticSearch集群中有未分配的分片,我不知道如何修复它。我删除了索引并再次创建它,但图片是一样的。
如何解决?
---编辑----
{
"cluster_name": "node_name",
"status": "yellow",
"timed_out": false,
"number_of_nodes": 2,
"number_of_data_nodes": 2,
"active_primary_shards": 8,
"active_shards": 12,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 4,
"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": 75
}
答案 0 :(得分:0)
我发现了问题!节点2.3.1和2.2.0有2个不同版本。因为我昨天使用当前版本更新了ElasticSearch,所以我应该手动更新第二个节点,因为它位于同一台服务器上。因为版本不同,所以有这种未分割的碎片。
谢谢!
答案 1 :(得分:-1)
下面是一个可以强制修复的bash(将服务器名称更改为目标节点):
IFS=$'\n'
for line in $(curl -s 'localhost:9200/_cat/shards' | fgrep UNASSIGNED); do
INDEX=$(echo $line | (awk '{print $1}'))
SHARD=$(echo $line | (awk '{print $2}'))
curl -XPOST 'localhost:9200/_cluster/reroute' -d '{
"commands": [
{
"allocate": {
"index": "'$INDEX'",
"shard": '$SHARD',
"node": "SERVER_NAME_OF_THE TARGET_NODE",
"allow_primary": true
}
}
]
}'