Created
September 25, 2015 01:28
-
-
Save sh4t/597a029ebaedb672576f to your computer and use it in GitHub Desktop.
Revisions
-
sh4t created this gist
Sep 25, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ #!/bin/bash # danger! danger! # IFS=$'\n' for line in $(curl -s 'localhost:9200/_cat/shards' | fgrep '0 r UNASSIGNED'); do #for line in $(curl -s 'localhost:9200/_cat/shards' | fgrep 'UNASSIGNED'); do INDEX=$(echo $line | (awk '{print $1}')) SHARD=$(echo $line | (awk '{print $2}')) SHARD_TYPE=$(echo $line | (awk '{print $3'})) curl -XPOST 'localhost:9200/_cluster/reroute' -d '{ "commands": [ { "allocate": { "index": "'$INDEX'", "shard": '$SHARD', "node": "data3-sjc1", "allow_primary": true } } ] }' >> ./data3.json # a way I can comment out above and then run # the loop with these conditions to see what is primary # versus what is replica # # if [ "Z${SHARD_TYPE}" == "Zr" ] # then # echo "${INDEX} ${SHARD} [replica]" # elif [ "Z${SHARD_TYPE}" == "Zp" ] # then # echo "${INDEX} ${SHARD} [primary]" # else # exit 99 # fi done