elasticsearch(二): 基础的查询语句,这些查询语句都跑一遍,离入门就差半步了

目录

ES 基础操作第一阶段

1、查询es 基础信息

2、/_cat/allocation       #查看单节点的shard 分片 分配整体情况

3、/_cat/shards/{index}   #查看指定分片的详细情况

4、/_cat/nodes           #查看所有节点信息

5、/_cat/indices         #查看集群中所有index的详细信息

6、/_cat/indices/{index} #查看集群中指定index的详细信息

7、/_cat/segments/{index}#查看指定index的segment详细信息

8、/_cat/count           #查看当前集群的doc数量

9、/_cat/count/{index}   #查看指定索引的doc数量

10、/_cat/recovery        #查看集群内每个shard的recovery过程.调整replica。

11、/_cat/recovery/{index}#查看指定索引shard的recovery过程

12、/_cat/health          #查看集群当前状态:红、黄、绿

13、/_cat/pending_tasks   #查看当前集群的pending task

14/_cat/aliases         #查看集群中所有alias信息,路由配置等

15、/_cat/aliases/{alias} #查看指定索引的alias信息

16、/_cat/plugins         #查看集群各个节点上的plugin信息

17、/_cat/fielddata       #查看当前集群各个节点的fielddata内存使用情况

18、/_cat/fielddata/{fields}     #查看指定field的内存使用情况,里面传field属性对应的值

19、/_cat/nodeattrs              #查看单节点的自定义属性

20、/_cat/repositories           #输出集群中注册快照存储库

21、/_cat/templates              #输出当前正在存在的模板信息

22、/_mapping?pretty=true # 列出每个Index 包含的Type



ES 基础操作第一阶段

1、查询es 基础信息

[root@vcontroller analysis-pinyin]# curl http://localhost:9200
{
  "name" : "vcontroller",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "H97dmoK7SNSHkUK0prmV6g",
  "version" : {
    "number" : "7.10.2",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "747e1cc71def077253878a59143c1f785afa92b9",
    "build_date" : "2021-01-13T00:42:12.435326Z",
    "build_snapshot" : false,
    "lucene_version" : "8.7.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

感谢以下博客收集,我在这里面做一下操作扩展:

Es 查看集群详细信息_若无梦何远方-CSDN博客_es查看集群状态

2、/_cat/allocation       #查看单节点的shard 分片 分配整体情况

[root@vcontroller ~]# curl -X GET 'http://localhost:9200/_cat/allocation'

0 0b 3.9gb 45.9gb 49.9gb 7 172.18.46.90 172.18.46.90 vcontroller

 [root@cloud elk]# curl -X GET 'localhost:9201/_cat/allocation?v'
shards disk.indices disk.used disk.avail disk.total disk.percent host         ip           node

分片数  索引占用磁盘大小    磁盘已使用 磁盘可供数据剩余  磁盘总容量 ?     ? ? 节点名 

[root@cloud elk]# curl -X GET 'localhost:9201/_cat/allocation?v'
shards disk.indices disk.used disk.avail disk.total disk.percent host         ip           node
     5         41mb     2.6gb     47.3gb     49.9gb            5 172.18.46.55 172.18.46.55 node-1

/_cat/shards          #查看各shard的详细情况

curl -X GET 'http://localhost:9200/_cat/shards'

[root@cloud elk]# curl -X GET 'localhost:9201/_cat/shards?v'
index               shard prirep state   docs store ip           node
.geoip_databases    0     p      STARTED   42  41mb 172.18.46.55 node-1
original-2021.09.09 1     p      STARTED    0  208b 172.18.46.55 node-1
original-2021.09.09 3     p      STARTED    0  208b 172.18.46.55 node-1
original-2021.09.09 2     p      STARTED    0  208b 172.18.46.55 node-1
original-2021.09.09 0     p      STARTED    0  208b 172.18.46.55 node-1

3、/_cat/shards/{index}   #查看指定分片的详细情况

/_cat/master          #查看master节点信息

[root@vcontroller ~]# curl -X GET 'http://localhost:9200/_cat/master'

[root@cloud elk]# curl -X GET 'localhost:9201/_cat/shards/original-2021.09.09?v'
index               shard prirep state   docs store ip           node
original-2021.09.09 1     p      STARTED    0  208b 172.18.46.55 node-1
original-2021.09.09 3     p      STARTED    0  208b 172.18.46.55 node-1
original-2021.09.09 2     p      STARTED    0  208b 172.18.46.55 node-1
original-2021.09.09 0     p      STARTED    0  208b 172.18.46.55 node-1

4、/_cat/nodes           #查看所有节点信息

[root@vcontroller analysis-pinyin]# curl -X GET 'http://localhost:9200/_cat/nodes?v'

ip           heap.percent ram.percent cpu load_1m load_5m load_15m node.role  master name

172.18.46.90           36          74   4    0.18    0.33     0.24 cdhilmrstw *      vcontroller

[root@cloud elk]# curl -X GET 'localhost:9201/_cat/nodes?v'
ip           heap.percent ram.percent cpu load_1m load_5m load_15m node.role   master name
172.18.46.55           56          97   0    0.08    0.04     0.05 cdfhilmrstw *      node-1

5、/_cat/indices         #查看集群中所有index的详细信息

curl -X GET 'http://localhost:9200/_cat/indices?v'

如果出现以下输出,说明我们尚未创建任何索引

health status index uuid pri rep docs.count docs.deleted store.size pri.store.size

[root@cloud elk]# curl -XGET 127.0.0.1:9201/_cat/indices?v&h=shard,segment,size,size.memory
[1] 18076
[root@cloud elk]# health status index               uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   .geoip_databases    b9yjaHIWSi6xgNMfnLNM5Q   1   0         42            0       41mb           41mb
green  open   original-2021.09.09 flKvNLkSQi-xxaIJ9C3bkg   4   0          0            0       832b           832b

6、/_cat/indices/{index} #查看集群中指定index的详细信息

[root@cloud elk]# curl -XGET 127.0.0.1:9201/_cat/indices/original-2021.09.09?v
health status index               uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   original-2021.09.09 flKvNLkSQi-xxaIJ9C3bkg   4   0          0            0       832b           832b


7、/_cat/segments/{index}#查看指定index的segment (分片)详细信息

 /_cat/segments        #查看各index的segment详细信息,包括segment名, 所属shard, 内存(磁盘)占用大小,是否刷盘

[root@vcontroller ~]# curl -X GET 'http://localhost:9200/_cat/segments'

[root@cloud elk]# curl -XGET 127.0.0.1:9201/_cat/segments/.geoip_databases?v&h=shard,segment,size,size.memory
[1] 17967
[root@cloud elk]# index            shard prirep ip           segment generation docs.count docs.deleted    size size.memory committed searchable version compound
.geoip_databases 0     p      172.18.46.55 _b              11         10            0   9.9mb        1092 true      true       8.9.0   false
.geoip_databases 0     p      172.18.46.55 _l              21         10            0    10mb        1188 true      true       8.9.0   false
.geoip_databases 0     p      172.18.46.55 _m              22          1            0   969kb        1076 true      true       8.9.0   true
.geoip_databases 0     p      172.18.46.55 _n              23          1            0 978.6kb        1076 true      true       8.9.0   true
.geoip_databases 0     p      172.18.46.55 _o              24          1            0 991.5kb        1076 true      true       8.9.0   true
.geoip_databases 0     p      172.18.46.55 _p              25          1            0 975.2kb        1076 true      true       8.9.0   true
.geoip_databases 0     p      172.18.46.55 _q              26          1            0 996.8kb        1076 true      true       8.9.0   true
.geoip_databases 0     p      172.18.46.55 _r              27          1            0     1mb        1076 true      true       8.9.0   true
.geoip_databases 0     p      172.18.46.55 _s              28         13            0  12.4mb        1092 true      true       8.9.0   true
.geoip_databases 0     p      172.18.46.55 _t              29          1            0     1mb        1076 true      true       8.9.0   true
.geoip_databases 0     p      172.18.46.55 _u              30          1            0 974.5kb        1076 true      true       8.9.0   true
.geoip_databases 0     p      172.18.46.55 _v              31          1            0 958.1kb        1076 true      true       8.9.0   true

8、/_cat/count           #查看当前集群的doc数量

[root@vcontroller ~]# curl -X GET 'http://localhost:9200/_cat/count'

1611805490 03:44:50 0

[root@cloud elk]# curl -XGET 127.0.0.1:9201/_cat/count?v
epoch      timestamp count
1631244876 03:34:36  0

9、/_cat/count/{index}   #查看指定索引的doc数量

10、/_cat/recovery        #查看集群内每个shard的recovery过程.调整replica。

[root@vcontroller ~]# curl -X GET 'http://localhost:9200/_cat/recovery'

[root@cloud elk]# curl -XGET 127.0.0.1:9201/_cat/recovery?v
index               shard time  type        stage source_host source_node target_host  target_node repository snapshot files files_recovered files_percent files_total bytes bytes_recovered bytes_percent bytes_total translog_ops translog_ops_recovered translog_ops_percent
original-2021.09.09 0     190ms empty_store done  n/a         n/a         172.18.46.55 node-1      n/a        n/a      0     0               0.0%          0           0     0               0.0%          0           0            0                      100.0%
original-2021.09.09 1     109ms empty_store done  n/a         n/a         172.18.46.55 node-1      n/a        n/a      0     0               0.0%          0           0     0               0.0%          0           0            0                      100.0%
original-2021.09.09 2     214ms empty_store done  n/a         n/a         172.18.46.55 node-1      n/a        n/a      0     0               0.0%          0           0     0               0.0%          0           0            0                      100.0%
original-2021.09.09 3     126ms empty_store done  n/a         n/a         172.18.46.55 node-1      n/a        n/a      0     0               0.0%          0           0     0               0.0%          0           0            0                      100.0%

11、/_cat/recovery/{index}#查看指定索引shard的recovery过程

12、/_cat/health          #查看集群当前状态:红、黄、绿

[root@vcontroller]# curl -X GET 'http://localhost: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

1611804557 03:29:17  elasticsearch green           1         1      0   0    0    0        0             0                  -                100.0%

[root@cloud elk]# curl -XGET 127.0.0.1:9201/_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
1631255457 06:30:57  elasticsearch green           1         1      5   5    0    0        0             0                  -                100.0%

13、/_cat/pending_tasks   #查看当前集群的pending task

[root@vcontroller ~]# curl -X GET 'http://localhost:9200/_cat/pending_tasks'

[root@cloud elk]# curl -XGET 127.0.0.1:9201/_cat/pending_tasks?v
insertOrder timeInQueue priority source

14/_cat/aliases         #查看集群中所有alias信息,路由配置等

[root@vcontroller ~]# curl -X GET 'http://localhost:9200/_cat/aliases'

[root@cloud elk]# curl -XGET 127.0.0.1:9201/_cat/aliases?v
alias index filter routing.index routing.search is_write_inde

15、/_cat/aliases/{alias} #查看指定索引的alias信息

/_cat/thread_pool     #查看集群各节点内部不同类型的threadpool的统计信息,

16、/_cat/plugins         #查看集群各个节点上的plugin信息

[root@vcontroller ~]# curl -X GET 'http://localhost:9200/_cat/plugins'

[root@cloud elk]# curl -XGET 127.0.0.1:9201/_cat/plugins?v
name component version
vcontroller analysis-ik     7.10.2

vcontroller analysis-pinyin 7.10.

17、/_cat/fielddata       #查看当前集群各个节点的fielddata内存使用情况

[root@vcontroller ~]# curl -X GET 'http://localhost:9200/_cat/fielddata'

[root@cloud elk]# curl -XGET 127.0.0.1:9201/_cat/fielddata?v
id host ip node field size

18、/_cat/fielddata/{fields}     #查看指定field的内存使用情况,里面传field属性对应的值

19、/_cat/nodeattrs              #查看单节点的自定义属性

[root@cloud elk]# curl -XGET 127.0.0.1:9201/_cat/nodeattrs?v
node   host         ip           attr              value
node-1 172.18.46.55 172.18.46.55 ml.machine_memory 3973705728
node-1 172.18.46.55 172.18.46.55 xpack.installed   true
node-1 172.18.46.55 172.18.46.55 transform.node    true
node-1 172.18.46.55 172.18.46.55 ml.max_open_jobs  512
node-1 172.18.46.55 172.18.46.55 ml.max_jvm_size   1988100096

20、/_cat/repositories           #输出集群中注册快照存储库

[root@vcontroller ~]# curl -X GET 'http://localhost:9200/_cat/repositories'

[root@cloud elk]# curl -XGET 127.0.0.1:9201/_cat/repositories?v
id type

21、/_cat/templates              #输出当前正在存在的模板信息

[root@cloud elk]# curl -XGET 127.0.0.1:9201/_cat/templates?v
name                            index_patterns               order      version composed_of
.monitoring-alerts-7            [.monitoring-alerts-7]       0          7140099 
.monitoring-beats               [.monitoring-beats-7-*]      0          7140099 
.monitoring-kibana              [.monitoring-kibana-7-*]     0          7140099 
original                        [original-*]                 0                  
.monitoring-logstash            [.monitoring-logstash-7-*]   0          7140099 
.transform-notifications-000002 [.transform-notifications-*] 0          7140199 
.monitoring-es                  [.monitoring-es-7-*]         0          7140099 
.ml-state                       [.ml-state*]                 2147483647 7140199 []
ilm-history                     [ilm-history-5*]             2147483647 5       []
.slm-history                    [.slm-history-5*]            2147483647 5       []
synthetics                      [synthetics-*-*]             100        1       [synthetics-mappings, data-streams-mappings, synthetics-settings]
.ml-anomalies-                  [.ml-anomalies-*]            2147483647 7140199 []
metrics                         [metrics-*-*]                100        1       [metrics-mappings, data-streams-mappings, metrics-settings]
.ml-notifications-000002        [.ml-notifications-000002]   2147483647 7140199 []
.deprecation-indexing-template  [.logs-deprecation.*]        1000       1       [.deprecation-indexing-mappings, .deprecation-indexing-settings]
.watch-history-13               [.watcher-history-13*]       2147483647 13      []
logs                            [logs-*-*]                   100        1       [logs-mappings, data-streams-mappings, logs-settings]
.ml-stats                       [.ml-stats-*]                2147483647 7140199 []

22、/_mapping?pretty=true # 列出每个Index 包含的Type

[root@vcontroller ~]# curl -X GET 'http://localhost:9200/_mapping?pretty=true'

[root@cloud elk]# curl -XGET 127.0.0.1:9201/_mapping?pretty=true
{
  "original-2021.09.09" : {
    "mappings" : {
      "_source" : {
        "enabled" : false
      },
      "properties" : {
        "@timestamp" : {
          "type" : "date",
          "format" : "EEE MMM dd HH:mm:ss Z YYYY"
        },
        "@version" : {
          "type" : "keyword"
        },
        "InInterface" : {
          "type" : "keyword"
        },
        "Interfaces" : {
          "properties" : {
            "InterfaceList" : {
              "type" : "keyword"
            },
            "vmifList" : {
              "properties" : {
                "gateway" : {
                  "type" : "keyword"
                },
                "ip_address" : {
                  "type" : "keyword"
                },
                "vmif" : {
                  "type" : "keyword"
                }
              }
            }
          }
        },
        "Keyword" : {
          "type" : "keyword"
        },
        "Subject" : {
          "type" : "keyword"
        },
        "VMS" : {
          "properties" : {
            "VMIDList" : {
              "type" : "keyword"
            },
            "VMNameList" : {
              "type" : "keyword"
            }
          }
        },
        "VirusFileName" : {
          "type" : "keyword"
        },
        "geoip" : {
          "dynamic" : "true",
          "properties" : {
            "ip" : {
              "type" : "ip"
            },
            "latitude" : {
              "type" : "half_float"
            },
            "location" : {
              "type" : "geo_point"
            },
            "longitude" : {
              "type" : "half_float"
            }
          }
        },
        "host" : {
          "type" : "keyword"
        },
        "ip6_address" : {
          "type" : "keyword"
        },
        "ip_address" : {
          "type" : "keyword"
        }
      }
    }
  }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

千码君2016

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值