Created
March 23, 2015 15:42
-
-
Save garlandkr/5b007cf5b090b5d381c9 to your computer and use it in GitHub Desktop.
Assigning shards in ElasticSearch
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
# First get the unassigned shard indices | |
curl -XGET http://localhost:8080/_cat/shards --silent | grep UNASS | awk '{print$1,$2}' | awk '!a[$0]++' > indices.txt | |
# Now assign them to the proper node. | |
cat indices.txt | while read -r index shard; do | |
curl -XPOST 'localhost:8080/_cluster/reroute' -d "{ | |
\"commands\" : [ { | |
\"allocate\" : { | |
\"index\" : \"$index\", | |
\"shard\" : \"$shard\", | |
\"node\" : \"Mentor\", | |
\"allow_primary\" : true | |
} | |
} | |
] | |
}" | |
sleep 5 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment