Created
November 10, 2017 08:37
-
-
Save kszarek/81cc02168c165d11787b04ad5a161bd0 to your computer and use it in GitHub Desktop.
ElasticSearch: Removes all shards from given node's IP
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
#!/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