Skip to content

Instantly share code, notes, and snippets.

@kszarek
Created November 10, 2017 08:37
Show Gist options
  • Save kszarek/81cc02168c165d11787b04ad5a161bd0 to your computer and use it in GitHub Desktop.
Save kszarek/81cc02168c165d11787b04ad5a161bd0 to your computer and use it in GitHub Desktop.
ElasticSearch: Removes all shards from given node's IP
#!/bin/bash
set -e
if [[ $# -ne 1 ]]
then
echo "Removes all shards from given node's IP."
echo
echo "$0 source_node_IP|NONE"
exit 1
fi
NODE_IP=$1
if [[ $NODE_IP == "NONE" ]]
then
NODE_IP=""
fi
curl -XPUT localhost:9200/_cluster/settings -d '{
"transient" :{
"cluster.routing.allocation.exclude._ip" : "'${NODE_IP}'"
}
}';
echo
echo "Remember to execute the script with NONE argument after the node decommission."
echo "Otherwise new node with the same ip address will not work properly."
echo
echo "Have a nice day!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment