Skip to content

Instantly share code, notes, and snippets.

@ikuwow
Created April 20, 2016 04:37
Show Gist options
  • Save ikuwow/43cb5598d59f82fd7753fe0813564fe6 to your computer and use it in GitHub Desktop.
Save ikuwow/43cb5598d59f82fd7753fe0813564fe6 to your computer and use it in GitHub Desktop.
#!/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