These are the snippets I use most of the time when administrating my ES cluster
To be updated
curl -XPUT 'http://escluster:9200/_cluster/settings' -d '{
| # in /usr/local/bin/git-cleanup-merged | |
| #!/bin/sh | |
| #!/usr/bin/env bash | |
| current_branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') | |
| if [ "$current_branch" != "master" ] && [ "$current_branch" != "main" ]; then | |
| echo "WARNING: You are on branch $current_branch, NOT master or main." | |
| fi |
| # Before running that script, use Twitter backup CSV file to pick up the tweets | |
| # you want to delete. Save, then run: | |
| # cat tweets.csv | cut -f 2 -d '"' | grep '^[0-9]*$' | sed '/^$/d' > delete.csv | |
| # gem install twitter (in case you miss the gem already) | |
| require 'twitter' | |
| client = Twitter::REST::Client.new do |config| | |
| config.consumer_key = '' | |
| config.consumer_secret = '' |
| while true; do curl -XGET 'cluster:9200/_cat/thread_pool?v&h=host,search.queue,search.active,search.rejected,search.completed' | sort -unk 2,3 ; sleep 5 ; done |
| # normal | |
| curl -XPUT 'http://esmaster01.:9200/_cluster/settings' -d '{ | |
| "transient" : { | |
| "cluster.routing.allocation.cluster_concurrent_rebalance": 50, | |
| "indices.recovery.concurrent_streams": 50, | |
| "cluster.routing.allocation.node_initial_primaries_recoveries": 50, | |
| "cluster.routing.allocation.node_concurrent_recoveries": 50, | |
| "indices.recovery.max_bytes_per_sec": "2048mb", | |
| "cluster.routing.allocation.disk.threshold_enabled" : true, | |
| "cluster.routing.allocation.disk.watermark.low" : "70%", |
| # 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 }}' | |
| #!/bin/sh | |
| HOST=$1 | |
| CURL_BIN=$(which curl) | |
| if [ -z "$HOST" ]; then | |
| echo "Host is missing" | |
| exit 1 | |
| fi |
| #!/bin/sh | |
| HOST=$1 | |
| CURL_BIN=$(which curl) | |
| if [ -z "$HOST" ]; then | |
| echo "Host is missing" | |
| exit 1 | |
| fi |
I hereby claim:
To claim this, I am signing this object:
| #!/bin/bash -x | |
| #Tue Jul 2 15:32:21 CEST 2013 | |
| #Made by Edward Z. | |
| set -e #stops execution if a variable is not set | |
| set -u #stop execution if something goes wrong | |
| usage() { | |
| echo "usage: $(basename $0) [option]" | |
| echo "option=full: do a full backup of vinnie /var/lib/mysql using innobackupex, aprox time 6 hours." | |
| echo "option=incremental: do a incremental backup" |