Last active
November 23, 2021 14:39
-
-
Save zealot128/8b3e952a71be77bfa6a7f551b6854814 to your computer and use it in GitHub Desktop.
Elasticsearch: migrate ALL shards from a master node to other nodes (e.g. mark all shards to move to other node before shutting down)
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 | |
# cluster | |
server="10.10.10.153:9200" | |
# new master node name | |
target="node123" | |
# fetch all index names | |
indices=`curl $server/_cat/indices?h=index` | |
# if only one node should be left, set to 0 to change settings too | |
number_of_replicas=0 | |
for index in $indices | |
do | |
echo | |
echo "Moving $index..." | |
curl -XPUT $server/$index/_settings -H 'Content-Type: application/json' -d '{ "index.routing.allocation.include._name": "es.portal02.pludoni.com", "index.number_of_replicas": $number_of_replicas}' | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment