elasticsearch command

  1. 查看ES健康状态

    1
    2
    3
    [root@10 ~]# curl '10.0.3.40: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
    1489221736 16:42:16 ssp green 3 3 662 331 0 0 0 0 - 100.0%
  2. 查看集群节点

    1
    2
    3
    4
    5
    [root@10 ~]# curl '10.0.3.40:9200/_cat/nodes?v'  
    host ip heap.percent ram.percent load node.role master name
    10.0.3.40 10.0.3.40 49 97 0.89 d m 10.0.3.40
    10.0.3.41 10.0.3.41 58 98 0.71 d m 10.0.3.41
    10.0.3.42 10.0.3.42 61 97 1.09 d * 10.0.3.42
  3. 查看集群索引信息

    1
    2
    3
    4
    [root@10 ~]# curl '10.0.3.40:9200/_cat/indices?v'  
    health status index pri rep docs.count docs.deleted store.size pri.store.size
    green open index_1 5 1 12935206 0 10.5gb 5.2gb
    green open index_2 5 1 21408160 0 16.6gb 8.3gb
  4. 查看单条索引

    1
    2
    [root@10 soft]# curl -XGET http://10.0.3.40:9200/new-index?v
    [root@10 soft]# curl -XGET http://10.0.3.40:9200/new-index?pretty
  5. 关闭和打开索引

    1
    2
    curl -XPOST http://10.0.3.40:9200/new-index/_open
    curl -XPOST http://10.0.3.40:9200/new-index/_close
  6. 删除索引

    1
    curl -XDELETE http://10.0.3.40:9200/new-index
  7. 创建索引

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    //简单方法
    curl -XPUT http://10.0.3.40:9200/new-index

    //创建索引加参数
    curl -XPUT http://10.0.3.40:9200/new-index -d '
    {
    "settings":{
    "index":{
    "number_of_shards":3,
    "number_of_replicas":2
    }
    }
    }
    '
  8. 查看分片

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    [wisdom@10 ~]$ curl -XGET '10.0.3.41:9200/_cat/shards'|grep v2-inbound-request-2017.03
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    100 26082 100 26082 0 0 61893 0 --:--:-- --:--:-- --:--:-- 61952
    v2-inbound-request-2017.03 1 r STARTED 25071632 35.2gb 10.0.3.41 10.0.3.41
    v2-inbound-request-2017.03 1 p STARTED 25071643 35.2gb 10.0.3.40 10.0.3.40
    v2-inbound-request-2017.03 3 p STARTED 25107804 35.3gb 10.0.3.41 10.0.3.41
    v2-inbound-request-2017.03 3 r STARTED 25107796 35.3gb 10.0.3.42 10.0.3.42
    v2-inbound-request-2017.03 2 r STARTED 25098807 35.2gb 10.0.3.42 10.0.3.42
    v2-inbound-request-2017.03 2 p STARTED 25098799 35.2gb 10.0.3.40 10.0.3.40
    v2-inbound-request-2017.03 4 p STARTED 25108295 35.3gb 10.0.3.41 10.0.3.41
    v2-inbound-request-2017.03 4 r STARTED 25108301 35.3gb 10.0.3.42 10.0.3.42
    v2-inbound-request-2017.03 0 r STARTED 25105055 35.3gb 10.0.3.42 10.0.3.42
    v2-inbound-request-2017.03 0 p STARTED 25105050 35.3gb 10.0.3.40 10.0.3.40