[Elasticsearch] shard reroute 하기..

Elastic/Elasticsearch 2013. 12. 16. 17:04

간혹 elasticsearch 가 비정상 종료 되거나 했을 경우 unassigned shard 가 남는 경우가 있습니다.

이럴 경우 아래와 같이 재할당을 할 수 있는데요.

운영 하실 때 참고 하면 좋습니다.

[shard_reroute.sh]

#!/bin/bash

size=$#

if [ $size -ne 2 ]; then
    echo "Usage: shard.sh INDICE_NAME SHARD_NUMBER";
    echo "Example: shard.sh products 1";
    exit 0;
fi

indice=$1
shard=$2

echo "curl -XPOST http://localhost:9200/_cluster/reroute -d '{ "commands" : [ { "allocate" : { "index" : \"$indice\", "shard" : $shard, "node" : "node1", "allow_primary" : true } } ] }'"
echo ""
curl -XPOST http://localhost:9200/_cluster/reroute -d '{ "commands" : [ { "allocate" : { "index" : "'$indice'", "shard" : '$shard', "node" : "node1", "allow_primary" : true } } ] }'

[Reference URL]

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-reroute.html

: