Elasticsearch : drainer un membre du cluster

Parfois il peut être intéressant de “drainer” un membre de son cluster Elasticsearch de toutes ses données, avant de réaliser une maintenance planifiée par exemple.

Vous pouvez réaliser cette action en vous basant sur l’IP du noeud, son nom ou hostname :

curl -XPUT 'localhost:9200/_cluster/settings?pretty' -d '{
  "transient" : {
    "cluster.routing.allocation.exclude._ip" : "10.0.0.1"
  }
}'

curl -XPUT 'localhost:9200/_cluster/settings?pretty' -d '{
  "transient" : {
    "cluster.routing.allocation.exclude._ip" : "10.0.0.*"
  }
}'

curl -XPUT 'localhost:9200/_cluster/settings?pretty' -d '{
  "transient" : {
    "cluster.routing.allocation.exclude._name" : "els01"
  }
}'

curl -XPUT 'localhost:9200/_cluster/settings?pretty' -d '{
  "transient" : {
    "cluster.routing.allocation.exclude._hostname" : "els01.prd.sfo.domain.tld"
  }
}'