Created
April 20, 2016 04:37
-
-
Save ikuwow/43cb5598d59f82fd7753fe0813564fe6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# re-allocate shards of node "Wildboys" (ip=10.252.1.114) | |
variable=$(curl -X GET 10.252.1.114:9200/_cat/shards | grep UNASSIGNED | awk -v OFS=, '{print $1,$2,$3}') | |
for shard in $variable; do | |
index=$(echo $shard | cut -d, -f1) | |
snum=$(echo $shard | cut -d, -f2) | |
pr=$(echo $shard | cut -d, -f3) | |
echo | |
echo $index | |
echo $snum | |
echo | |
curl -X POST '10.252.1.114:9200/_cluster/reroute' -d "{ | |
\"commands\" : [ { | |
\"allocate\" : { | |
\"index\" : \"${index}\", | |
\"shard\" : ${snum}, | |
\"node\" : \"Wildboys\", | |
\"allow_primary\" : true | |
} | |
}] | |
}" | |
sleep 1 | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment