Skip to content

Instantly share code, notes, and snippets.

@FreeTymeKiyan
Last active June 8, 2017 08:53
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save FreeTymeKiyan/21a50205ede3774a90156ffc8057f3e5 to your computer and use it in GitHub Desktop.
Save FreeTymeKiyan/21a50205ede3774a90156ffc8057f3e5 to your computer and use it in GitHub Desktop.
HOST=YOUR_ES_HOST
PORT=YOUR_ES_PORT
TO_NODE=DESTINATION_NODE_NAME
curl "http://$HOST:$PORT/_cat/shards" | grep UNAS | awk '{print $1,$2}' | while read var_index var_shard; do
curl -XPOST "http://$HOST:$PORT/_cluster/reroute" -d "
{
\"commands\" : [
{
\"allocate\" :
{
\"index\" : \"$var_index\",
\"shard\" : $var_shard,
\"node\" : \"$TO_NODE\",
\"allow_primary\" : true
}
}
]
}" ;
sleep 5;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment