Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active April 2, 2023 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dacr/cf957becc76a7ef32a17117c15a7018e to your computer and use it in GitHub Desktop.
Save dacr/cf957becc76a7ef32a17117c15a7018e to your computer and use it in GitHub Desktop.
elasticsearch and opendistro public cheat sheet / published by https://github.com/dacr/code-examples-manager #8bf6e4a0-257f-425f-a2df-cbc4138a9d5a/abe0e3c07b1fd3716c9318874c67c924fb9f3bc0

elasticsearch/opendistro cheat sheet

remote access check with basic auth

curl -u $ELASTIC_USERNAME:$ELASTIC_PASSWORD $ELASTIC_URL

alias ecurl="curl -u $ELASTIC_USERNAME:$ELASTIC_PASSWORD"

ecurl $ELASTIC_URL

basic commands

ecurl $ELASTIC_URL/_cluster/health?pretty

ecurl $ELASTIC_URL/_cat/nodes?pretty

ecurl $ELASTIC_URL/_cat/indices/cem-*?s=index
ecurl $ELASTIC_URL/_cat/indices/cem-*?s=store.size
ecurl $ELASTIC_URL/_cat/indices/cem-*?s=docs.count

Information about an index settings

GET /.kibana/_settings?include_defaults

Debugging / maintenance

Maximum shard per node reached

  • symptoms / issues :
    error type: validation_exception, reason: Validation Failed: 1: this action would add [2] total shards,
    but this cluster currently has [2000]/[2000] maximum shards open;
    
  • solution :
    GET /_cluster/settings?include_defaults=true
    
    PUT /_cluster/settings
    {
      "persistent": {
        "cluster.max_shards_per_node":10000
      }
    }
    
  • GET /_cluster/stats to get the number of shards (fast)
  • GET _stats to get the number shards (slow)

unassigned shard & red indices

symptoms / issues :

  • cluster in red state
    • many indices in red state
      • unassigned shards
# -----------------------------------------------
# RECOVERING RED INDICES (UNASSIGNED SHARDS)
# https://www.fpcomplete.com/blog/2018/04/recover-your-elasticsearch/#:~:text=Despite%20overall%20Elasticsearch%20stability%2C%20it,running%20out%20of%20disk%20space.

GET _cluster/state/routing_table

GET _cat/shards?v

POST _cluster/reroute?retry_failed

# can take times, check progress using :

GET _cluster/health?pretty
# unassigned_shards should decrease & active_shards increase

GET _cat/shards?v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment