Skip to content

Instantly share code, notes, and snippets.

View FreeTymeKiyan's full-sized avatar
🎯
Focusing

Yang FreeTymeKiyan

🎯
Focusing
View GitHub Profile
HOST=YOUR_ES_HOST
PORT=YOUR_ES_PORT
TO_NODE=DESTINATION_NODE_NAME
curl "http://$HOST:$PORT/_cat/shards" | grep UNAS | awk '{print $1,$2}' | while read var_index var_shard; do
curl -XPOST "http://$HOST:$PORT/_cluster/reroute" -d "
{
\"commands\" : [
{
\"allocate\" :
@FreeTymeKiyan
FreeTymeKiyan / reroute.py
Created March 6, 2016 21:21
An example python script to reroute unassigned shards to NODE_NAME node thus recovering from the red cluster status
# example python script
# pip install requests before using requests
import requests
import json
HOSTNAME="your.elasticsearch.host.com" # hostname
PORT=9200 # port number
NODE_NAME="node001" # node to reroute to