Last active
December 29, 2016 11:20
-
-
Save jkordish/0148096c7800c50925c0 to your computer and use it in GitHub Desktop.
assigned all the unassigned shards quickly.
This file contains hidden or 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 -e | |
for index in $(curl -sXGET http://localhost:9200/_cat/shards | grep UNASSIGNED | awk '{print $1}' | uniq); do | |
i=1 | |
for shard in $(curl -XGET http://localhost:9200/_cat/shards?index=$index | grep UNASSIGNED | awk '{print $2}'); do | |
echo "$shard on $index going on datanode$i" | |
curl -sXPOST 'localhost:9200/_cluster/reroute' -d '{ | |
"commands" : [ { | |
"allocate" : { | |
"index" : "'$index'", | |
"shard" : '$shard', | |
"node" : "datanode'$i'", | |
"allow_primary" : true | |
} | |
} | |
] | |
}' &> /dev/null | |
sleep 5 | |
i=$((i + 1)) | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment