Last active
March 17, 2020 02:03
-
-
Save hivefans/eeb84f3c91f946f0e83d4f9d34d97476 to your computer and use it in GitHub Desktop.
|-|{"files":{"shardallocate.sh":{"env":"plain"}},"tag":"bigdata"}
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
| function reroute() { | |
| curl -XPOST 'localhost:9200/_cluster/reroute?pretty' -d '{ | |
| "commands" : [ { | |
| "allocate" : { | |
| "index" : "'$1'", | |
| "shard" : '$2' | |
| "allow_primary" : true, | |
| "node" : "<node>" | |
| } | |
| } | |
| ] | |
| }' > /dev/null | |
| sleep 1 | |
| } | |
| curl -s localhost:9200/_cluster/state?pretty | awk ' | |
| BEGIN {more=1} | |
| {if (/"UNASSIGNED"/) unassigned=1} | |
| {if (/"routing_nodes"/) more=0} | |
| {if (unassigned && /"shard"/) shard=$3} | |
| {if (more && unassigned && /"index"/) {print "reroute",$3, shard; unassigned=false}} | |
| ' > runit | |
| source runit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment