Last active
July 28, 2017 00:33
-
-
Save arledesma/1a9efb0e7bb82639c7f6a562bedc41fe to your computer and use it in GitHub Desktop.
ES scripts
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 | |
if [ -n "$1" ]; then index=$1; fi | |
if [ -n "$2" ]; then shard=$2; fi | |
if [ -n "$3" ]; then targetNode=$3; fi | |
curl -u es_admin:$ESPASS -sS -XPOST 'localhost:9200/_cluster/reroute' -d "{ | |
\"commands\" : [ { | |
\"allocate\" : { | |
\"index\" : \"${index}\", | |
\"shard\" : ${shard}, | |
\"node\" : \"${targetNode:-${recoveryNode}}\", | |
\"allow_primary\" : true | |
} | |
} | |
] | |
}" |
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 | |
index=$1 | |
shard=$2 | |
node=$3 | |
targetNode=$4 | |
allocate="" | |
[ -z "${node}" ] && echo "Usage: $0 indexName shardNumber primaryNode" && exit 1 | |
[ -n "${targetNode}" ] && allocate=", { \"allocate\": { \"index\": \"${index}\", \"shard\": ${shard}, \"node\": \"${targetNode}\", \"allow_primary\": true } }" | |
reroute="{\"commands\": [{ \"cancel\": { \"index\": \"${index}\", \"shard\": ${shard}, \"node\": \"${node}\", \"allow_primary\": true } }${allocate}]}" | |
curl -u es_admin:$ESPASS -s -XPOST localhost:9200/_cluster/reroute -d "${reroute}" |
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 | |
curl -s -u es_admin:$ESPASS localhost:9200/_cluster/state/blocks?pretty | grep -B2 "index closed" | grep -v description | grep -v '"4"' | awk | |
-d\" -f2 | xargs -n1 -I{} echo curl -u es_admin:$ESPASS "http://localhost:9200/{}/_alias/*" -XDELETE | bash -x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment