Created
February 20, 2016 16:27
-
-
Save fdv/ee58db6c3da3bd31939e to your computer and use it in GitHub Desktop.
Rolling optimize of an ElasticSearch cluster
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/sh | |
HOST=$1 | |
CURL_BIN=$(which curl) | |
if [ -z "$HOST" ]; then | |
echo "Host is missing" | |
exit 1 | |
fi | |
if [ -z "$CURL_BIN" ]; then | |
echo "Curl binary is missing" | |
exit 1 | |
fi | |
while [ true ]; do | |
for indice in $(${CURL_BIN} -XGET http://${HOST}:9200/_cat/indices | sort -rk 6 | awk '{print $3}'); do | |
if [ ! -z "$indice" ]; then | |
echo "Processing indice ${indice}" | |
${CURL_BIN} -XPOST http://${HOST}:9200/${indice}/_optimize?max_num_segments=1 | |
echo | |
fi | |
done | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment