Last active
March 10, 2016 19:54
-
-
Save fforbeck/5857671bfe696b2706fe to your computer and use it in GitHub Desktop.
Allocate unassigned shard from Elasticsearch node
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
## | |
# http://stackoverflow.com/questions/19967472/elasticsearch-unassigned-shards-how-to-fix | |
## | |
NODE="YOUR NODE NAME" | |
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": "'$NODE'", | |
"allow_primary": true | |
} | |
} | |
] | |
}' | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment