Created
March 13, 2018 07:32
-
-
Save lgaggini/08dff867af926094f2d47cd26ae044b4 to your computer and use it in GitHub Desktop.
Simple script to force reallocation of unassigned primary shard
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
HOST={{ some_master_hostname/ip address }} | |
PORT=9200 | |
TO_NODE="{{ destination_node }}" | |
curl "http://$HOST:$PORT/_cat/shards" | grep UNAS | awk '{print $1" "$2}' | while read var_index var_shard; do | |
curl -XPOST "http://$HOST:$PORT/_cluster/reroute?pretty" -H 'Content-Type: application/json' -d " | |
{ | |
\"commands\" : [ | |
{ | |
\"allocate_stale_primary\": | |
{ | |
\"index\" : \"$var_index\", | |
\"shard\" : \"$var_shard\", | |
\"node\" : \"$TO_NODE\", | |
\"accept_data_loss\": true | |
} | |
} | |
] | |
}"; | |
sleep 5; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment