Last active
August 27, 2016 12:03
-
-
Save fdv/a4cf10c2c3556f3cc5f2245699a8bb1b to your computer and use it in GitHub Desktop.
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
# Mass index deletion with pattern | |
for index in $(curl -XGET esmaster:9200/_cat/indices | grep pattern | awk '{print $3}'); do curl -XDELETE esmaster:9200/$index?master_timeout=120s; done | |
# Mass optimize, indexes with the most deleted docs first | |
for indice in $(CURL -XGET esmaster:9200/_cat/indices | sort -rk 7 | awk '{print $3}'); do curl -XPOST http://esmaster:9200/${indice}/_optimize?max_num_segments=1; done | |
# Restart half a cluster using rack awareness | |
curl -XPUT 'host:9200/_cluster/settings' -d '{ "transient" : { "cluster.routing.allocation.enable": "none" }}'; for host in $(curl -XGET esmaster:9200/_cat/nodeattrs?attr | grep rack_id | awk '{print $2}'); do ssh $host service elasticsearch restart; done; sleep60; curl -XPUT 'host:9200/_cluster/settings' -d '{ "transient" : { "cluster.routing.allocation.enable": "all }}' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment