elasticsearch exploring your cluster

  1. cluster health

    1
    2
    3
    4
    5
    6
    penn@ubuntu:~$ curl -XGET http://127.0.0.1:9200/_cat/health?v
    epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
    1478891791 03:16:31 escluster green 1 1 0 0 0 0 0 0 - 100.0%

    cluster cluster名字
    status green表示正常;yellow表示data正常,但replica不正常;red表示有问题
  2. nodes check

    1
    2
    3
    penn@ubuntu:~$ curl -XGET http://127.0.0.1:9200/_cat/nodes?v
    ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
    127.0.0.1 6 98 0 0.00 0.00 0.00 mdi * esnode
  3. List All Indices

    1
    2
    penn@ubuntu:~$ curl -XGET http://127.0.0.1:9200/_cat/indices?v
    health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
  4. Create an index

    1
    2
    3
    4
    5
    6
    7
    8
    9
    penn@ubuntu:~$ curl -XPUT http://127.0.0.1:9200/customer?pretty
    {
    "acknowledged" : true,
    "shards_acknowledged" : true
    }

    penn@ubuntu:~$ curl -XGET http://127.0.0.1:9200/_cat/indices?v
    health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
    yellow open customer QRuRC4l0QBGJlX3BWGI1yQ 5 1 0 0 260b 260b
  5. Index and Query a Document

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    penn@ubuntu:~$ curl -XPUT '127.0.0.1:9200/customer/external/1?pretty&pretty' -d'
    > {
    > "name": "penn"
    > }'
    {
    "_index" : "customer",
    "_type" : "external",
    "_id" : "1",
    "_version" : 1,
    "result" : "created",
    "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
    },
    "created" : true
    }
    penn@ubuntu:~$ curl -XGET '127.0.0.1:9200/customer/external/1?pretty'
    {
    "_index" : "customer",
    "_type" : "external",
    "_id" : "1",
    "_version" : 1,
    "found" : true,
    "_source" : {
    "name" : "penn"
    }
    }
  6. Delete an index

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    penn@ubuntu:~$ curl -XGET http://127.0.0.1:9200/_cat/indices?v
    health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
    yellow open customer QRuRC4l0QBGJlX3BWGI1yQ 5 1 1 0 3.7kb 3.7kb

    penn@ubuntu:~$ curl -XDELETE http://127.0.0.1:9200/customer?pretty
    {
    "acknowledged" : true
    }

    penn@ubuntu:~$ curl -XGET http://127.0.0.1:9200/_cat/indices?v
    health status index uuid pri rep docs.count docs.deleted store.size pri.store.size