Last active
December 31, 2015 04:59
-
-
Save tehmaspc/7937710 to your computer and use it in GitHub Desktop.
Reallocating ElasticSearch Unassigned Shards
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -f | |
IFS=' | |
' | |
# NOTE1: file 'list_of_unassigned_shards.txt' should be present | |
# NOTE2: list of unassigned shards in file should be in '<SHARD> <INDEX>' format (per line). | |
MASTER_NODE='anDcaGBJRY2WXJe_rOjdMQ' # master node in cluster | |
MASTER_NODE_IP='10.199.242.111' # ip address of master node in cluster | |
for i in `cat list_of_unassigned_shards.txt`; do | |
SHARD=`echo $i | awk -F ' ' '{print $1}'` | |
INDEX=`echo $i | awk -F ' ' '{print $2}'` | |
POST_STRING="{\"commands\":[{\"allocate\":{\"index\":\"${INDEX}\",\"shard\":${SHARD},\"node\":\"${MASTER_NODE}\",\"allow_primary\":1}}]}'" | |
curl XPOST -s "http:\/\/${MASTER_NODE_IP}:9200\/_cluster\/reroute?pretty=true" -d $POST_STRING &>/dev/null | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment