Elasticsearch
Delete Index
curl -XDELETE localhost:9200/[index]?master_timeout=5m
allocate unassigned shards
range=2
IFS=$'\n'
for line in $(curl -s 'localhost:9200/_cat/shards' | fgrep UNASSIGNED); do
INDEX=$(echo $line | (awk '{print $1}'))
SHARD=$(echo $line | (awk '{print $2}'))
number=$RANDOM
let "number %= ${range}"
curl -H 'Content-Type:application/json' -XPOST http://localhost:9200/_cluster/reroute? -d '{
"commands" : [ {
"allocate_empty_primary" :
{
"index" : '\"${INDEX}\"',
"shard" : '\"${SHARD}\"',
"node" : "tigger-1",
"accept_data_loss" : true
}
}
]
}'
done
Truncate Corrupted Translog of Index
You should run the following command to allocate this shard:
curl -XPOST --header 'Content-Type: application/json' http://localhost:9200/_cluster/reroute -d '
{
"commands" : [
{
"allocate_stale_primary" : {
"index" : "graylog_9",
"shard" : 0,
"node" : "zYNG7nZMRWCNCDlqsDhKkw",
"accept_data_loss" : true
}
}
]
}'