Skip to content

Instantly share code, notes, and snippets.

@shirakaba
Last active November 13, 2020 22:28
Show Gist options
  • Save shirakaba/242c88aa4e5d8d9617d930c710d0aa4b to your computer and use it in GitHub Desktop.
Save shirakaba/242c88aa4e5d8d9617d930c710d0aa4b to your computer and use it in GitHub Desktop.
ElasticSearch cookbook

List the indices

curl -XGET 'localhost:9200/_all/_settings'
{
  "logstash-my-project-2020.04.16": {
    "settings": {
      "index": {
        "refresh_interval": "5s",
        "number_of_shards": "5",
        "provided_name": "logstash-my-project-2020.04.16",
        "creation_date": "1586995225612",
        "number_of_replicas": "1",
        "uuid": "yHA75LRSQ1GpKnG_3Ob5Bw",
        "version": {
          "created": "6030299"
        }
      }
    }
  }
}

Get the cluster settings

curl -XGET http://localhost:9200/_cluster/settings

This will tell you whether any watermarks are configured, for example.

Update the cluster watermark settings

See https://stackoverflow.com/questions/27547091/primary-shard-is-not-active-or-isnt-assigned-is-a-known-node

curl -XPUT -H 'Content-Type: application/json' 'http://localhost:9200/_cluster/settings' -d '{  "transient":{
   "cluster.routing.allocation.disk.watermark.low":"95%",
   "cluster.routing.allocation.disk.watermark.high": "97%",
   "cluster.routing.allocation.disk.watermark.flood_stage": "98%",
   "cluster.info.update.interval": "1m"
}}'

Update all settings to lift read-only mode

See https://stackoverflow.com/questions/50609417/elasticsearch-error-cluster-block-exception-forbidden-12-index-read-only-all

curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment