[elasticsearch 2.x]


  • start script – /etc/init.d/elasticsearch
    • contains also env variables like ES_JAVA_OPTS but they can be ignored – you must set them in default file
  • /etc/default/elasticsearch
    • this contains env variables which are actually taken into start
    • ES_HOME=/usr/share/elasticsearch
    • CONF_DIR=/etc/elasticsearch
    • DATA_DIR=/var/lib/elasticsearch
    • LOG_DIR=/var/log/elasticsearch
  • /etc/elasticsearch/elasticsearch.yml
    • network.bind_host:
    • cluster.name: youruniquenodename
      node.name: “masternode”
      node.master: true
      node.data: true


Elasticsearch installation:

  • install Oracle Java – you need to check which version is either latest or proper for your intended version of Elasticsearch) – here is ansible playbook for Java 8 it can help
  • download elasticsearch package of proper version you need from elastic.co (usually the latest but it can be the case you need to keep some older version – they are all still available)
  • install Elasticsearch sudo dpkg -i elasticsearchpackage
  • stop elasticsearch if it is running sudo service elasticsearch stop
  • in /etc/default/elasticsearch set
    • according to ES version set memory limits
      • 2.x – ES_HEAP_SIZE, ES_JAVA_OPTS
    • set data directory – DATA_DIR (if you want to use different disk etc.)
  • revize /etc/elasticsearch/elasticsearch.yml
    • name of the node etc.
  • start elasticsearch as service
  • as first step import schema !!! Schema looks like this (for ES 2.x):
    curl -XPOST 'http://localhost:9200/dashboards' -d'
        "mappings": {
          "metrics": {
            "properties": {
              "@metricname": {
                "type": "string"
              "@timestamp": {
                "format": "epoch_millis",
                "type": "date"
        "settings": {
          "index": {
            "number_of_replicas": "1",
            "number_of_shards": "10"
        "warmers": {}



JSON output can be “prettified” by adding “?pretty” parameter at the end of URL (or “&pretty=true” if URL already has some parameters)

  • statistics:
    curl -XGET localhost:9200/_stats
    curl -XGET localhost:9200/_nodes/stats
    • statistics only for fields memory:
      curl -XGET localhost:9200/_stats/fielddata?fields=*
  • flush cache:
    curl -XPOST localhost:9200/_flush
  • get health status:
    curl -XGET localhost:9200/_cluster/health
  • get list of nodes:
    curl -XGET localhost:9200/_cluster/nodes
  • shutdown cluster:
    curl -XPOST localhost:9200/_cluster/nodes/_shutdown