elasticsearch 学习笔记之二 常见接口

news/2024/12/5 13:25:25/文章来源:https://www.cnblogs.com/sandyflower/p/18581066

一、索引操作类

1、创建索引(PUT /索引名称)

PUT /my-index-000001

请求body

{"settings": {"index": {"number_of_shards": 3,   //创建3个主片"number_of_replicas": 2   //每个主片都会有两个副本
    }}
}

 

未指定mapping的情况下,使用默认的

2、删除索引(DELETE  /索引) (会删除索引的数据及其配置)   DELETE /iotrm_event_event_acs* 表示删除 iotrm_event_event_acs 开头的索引

注意:使用 Delete Index API 是不可逆的操作,一旦执行,索引及其所有数据都将被永久删除

 http://10.19.214.13:9200/data_iotrm_event_event_acs%240x00030403_2024-10-29?pretty     --- 删除索引data_iotrm_event_event_acs$0x00030403_2024-10-29

3、修改索引

 

 4、查看某个索引下的文档数据总量(GET /索引名称/_count)

http://10.19.223.119:9200/iotrm_event_cl2event_2024-10-29/_count

{"count": 155701,"_shards": {"total": 3,"successful": 3,"skipped": 0,"failed": 0}
}

5、查看所有索引信息(GET _cat/indices?v&format)  --- 包括数据量、占用大小

http://10.19.223.119:9200/_cat/indices?v

 

列说明:

  • pri:主片数量
  • rep:副本数量
  • store.size:总共存储大小(主片+副本)
  • pri.store.size:主片大小

6、查看某个索引信息(GET _cat/indices/索引名称?v&format) --- 包括数据量、占用大小

http://10.19.223.119:9200/_cat/indices/iotrm_event_cl2telemeter_2024-09-20?v
query参数:bytes="b", format="json"

 

7、关闭所有索引(POST /*/_close)  --- 关闭某个索引 将*替换成具体的索引名称即可,多个明确的索引要关闭的话可以使用逗号隔开

http://10.19.214.13:9200/*/_close

8、打开所有索引(POST /*/_open)  --- 打开某个索引 将*替换成具体的索引名称即可,多个明确的索引要打开的话可以使用逗号隔开

http://10.19.214.13:9200/*/_open

9、查看一个索引数据实际分布到各个节点机器的不同分片的情况(GET /_cat/shards/索引名称)

http://10.19.223.119:9200/_cat/shards/iotrm_event_event_towercrane$0x00054001_2024-10-29?v

 

图上可以看到这个索引副本都没有创建

10、查看一个索引定义信息,包括 aliases、mappings、settings(GET /索引名称)

http://10.19.223.119:9200/iotrm_event_temperaturetelemeter_2024-10-29

{"iotrm_event_temperaturetelemeter_2024-10-29": {"aliases": {},"mappings": {"properties": {"IOTProtocolType": {"type": "long"},"basic": {"properties": {"IOTProtocolType": {"type": "long"},"UUID": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"channelIndexCode": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"dateTime": {"type": "date"},"domain": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"eventType": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"imageServerCode": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"indexCode": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"ipV4Address": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"ipV6Address": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"localIndex": {"type": "long"},"macAddress": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"resourceCategory": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"sendTime": {"type": "date"}}},"dataType": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"eventType": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"targetAttrs": {"properties": {"cameraIndexCode": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"customCategory": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"deviceCategory": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"deviceIndexCode": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"deviceName": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"deviceType": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"extendDeviceCode": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"modelId": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"orgPath": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"tenantId": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}}}},"telemeter": {"properties": {"tag": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"test": {"type": "long"},"value": {"type": "float"}}}}},"settings": {"index": {"routing": {"allocation": {"include": {"_tier_preference": "data_content"}}},"number_of_shards": "3","provided_name": "iotrm_event_temperaturetelemeter_2024-10-29","creation_date": "1730365148113","number_of_replicas": "1","uuid": "XAQiTzvoTwGDYi2DMGeRJA","version": {"created": "7100299"}}}}
}

 

 

 

11、查看某个索引的 primary 存储信息(GET /索引名称/_stats/store)

http://10.19.223.119:9200/iotrm_event_event_towercrane%240x00054001_2024-10-29/_stats/store

{"_shards": {"total": 6,"successful": 3,"failed": 0},"_all": {"primaries": {"store": {"size_in_bytes": 13069189,"reserved_in_bytes": 0}},"total": {"store": {"size_in_bytes": 13069189,"reserved_in_bytes": 0}}},"indices": {"iotrm_event_event_towercrane$0x00054001_2024-10-29": {"uuid": "LUuow0N6TCOEvIDnYu1eUQ","primaries": {"store": {"size_in_bytes": 13069189,"reserved_in_bytes": 0}},"total": {"store": {"size_in_bytes": 13069189,"reserved_in_bytes": 0}}}}
}

 

12、查看指定索引的统计信息(GET /索引名称/_stats)

http://10.19.223.119:9200/iotrm_event_event_towercrane%240x00054001_2024-10-29/_stats

{"_shards": {"total": 6,"successful": 3,"failed": 0},"_all": {"primaries": {"docs": {"count": 36927,"deleted": 5767},"store": {"size_in_bytes": 13069189,"reserved_in_bytes": 0},"indexing": {"index_total": 0,"index_time_in_millis": 0,"index_current": 0,"index_failed": 0,"delete_total": 1444,"delete_time_in_millis": 98,"delete_current": 0,"noop_update_total": 0,"is_throttled": false,"throttle_time_in_millis": 0},"get": {"total": 0,"time_in_millis": 0,"exists_total": 0,"exists_time_in_millis": 0,"missing_total": 0,"missing_time_in_millis": 0,"current": 0},"search": {"open_contexts": 0,"query_total": 1328,"query_time_in_millis": 1884,"query_current": 0,"fetch_total": 6,"fetch_time_in_millis": 131,"fetch_current": 0,"scroll_total": 3,"scroll_time_in_millis": 1412,"scroll_current": 0,"suggest_total": 0,"suggest_time_in_millis": 0,"suggest_current": 0},"merges": {"current": 0,"current_docs": 0,"current_size_in_bytes": 0,"total": 0,"total_time_in_millis": 0,"total_docs": 0,"total_size_in_bytes": 0,"total_stopped_time_in_millis": 0,"total_throttled_time_in_millis": 0,"total_auto_throttle_in_bytes": 62914560},"refresh": {"total": 15,"total_time_in_millis": 176,"external_total": 12,"external_total_time_in_millis": 186,"listeners": 0},"flush": {"total": 6,"periodic": 0,"total_time_in_millis": 4303},"warmer": {"current": 0,"total": 9,"total_time_in_millis": 0},"query_cache": {"memory_size_in_bytes": 0,"total_count": 0,"hit_count": 0,"miss_count": 0,"cache_size": 0,"cache_count": 0,"evictions": 0},"fielddata": {"memory_size_in_bytes": 1456,"evictions": 0},"completion": {"size_in_bytes": 0},"segments": {"count": 9,"memory_in_bytes": 92804,"terms_memory_in_bytes": 73152,"stored_fields_memory_in_bytes": 4584,"term_vectors_memory_in_bytes": 0,"norms_memory_in_bytes": 10304,"points_memory_in_bytes": 0,"doc_values_memory_in_bytes": 4764,"index_writer_memory_in_bytes": 0,"version_map_memory_in_bytes": 0,"fixed_bit_set_memory_in_bytes": 0,"max_unsafe_auto_id_timestamp": -1,"file_sizes": {}},"translog": {"operations": 0,"size_in_bytes": 165,"uncommitted_operations": 0,"uncommitted_size_in_bytes": 165,"earliest_last_modified_age": 24819785},"request_cache": {"memory_size_in_bytes": 348918,"evictions": 0,"hit_count": 174,"miss_count": 114},"recovery": {"current_as_source": 0,"current_as_target": 0,"throttle_time_in_millis": 0}},"total": {"docs": {"count": 36927,"deleted": 5767},"store": {"size_in_bytes": 13069189,"reserved_in_bytes": 0},"indexing": {"index_total": 0,"index_time_in_millis": 0,"index_current": 0,"index_failed": 0,"delete_total": 1444,"delete_time_in_millis": 98,"delete_current": 0,"noop_update_total": 0,"is_throttled": false,"throttle_time_in_millis": 0},"get": {"total": 0,"time_in_millis": 0,"exists_total": 0,"exists_time_in_millis": 0,"missing_total": 0,"missing_time_in_millis": 0,"current": 0},"search": {"open_contexts": 0,"query_total": 1328,"query_time_in_millis": 1884,"query_current": 0,"fetch_total": 6,"fetch_time_in_millis": 131,"fetch_current": 0,"scroll_total": 3,"scroll_time_in_millis": 1412,"scroll_current": 0,"suggest_total": 0,"suggest_time_in_millis": 0,"suggest_current": 0},"merges": {"current": 0,"current_docs": 0,"current_size_in_bytes": 0,"total": 0,"total_time_in_millis": 0,"total_docs": 0,"total_size_in_bytes": 0,"total_stopped_time_in_millis": 0,"total_throttled_time_in_millis": 0,"total_auto_throttle_in_bytes": 62914560},"refresh": {"total": 15,"total_time_in_millis": 176,"external_total": 12,"external_total_time_in_millis": 186,"listeners": 0},"flush": {"total": 6,"periodic": 0,"total_time_in_millis": 4303},"warmer": {"current": 0,"total": 9,"total_time_in_millis": 0},"query_cache": {"memory_size_in_bytes": 0,"total_count": 0,"hit_count": 0,"miss_count": 0,"cache_size": 0,"cache_count": 0,"evictions": 0},"fielddata": {"memory_size_in_bytes": 1456,"evictions": 0},"completion": {"size_in_bytes": 0},"segments": {"count": 9,"memory_in_bytes": 92804,"terms_memory_in_bytes": 73152,"stored_fields_memory_in_bytes": 4584,"term_vectors_memory_in_bytes": 0,"norms_memory_in_bytes": 10304,"points_memory_in_bytes": 0,"doc_values_memory_in_bytes": 4764,"index_writer_memory_in_bytes": 0,"version_map_memory_in_bytes": 0,"fixed_bit_set_memory_in_bytes": 0,"max_unsafe_auto_id_timestamp": -1,"file_sizes": {}},"translog": {"operations": 0,"size_in_bytes": 165,"uncommitted_operations": 0,"uncommitted_size_in_bytes": 165,"earliest_last_modified_age": 24819785},"request_cache": {"memory_size_in_bytes": 348918,"evictions": 0,"hit_count": 174,"miss_count": 114},"recovery": {"current_as_source": 0,"current_as_target": 0,"throttle_time_in_millis": 0}}},"indices": {"iotrm_event_event_towercrane$0x00054001_2024-10-29": {"uuid": "LUuow0N6TCOEvIDnYu1eUQ","primaries": {"docs": {"count": 36927,"deleted": 5767},"store": {"size_in_bytes": 13069189,"reserved_in_bytes": 0},"indexing": {"index_total": 0,"index_time_in_millis": 0,"index_current": 0,"index_failed": 0,"delete_total": 1444,"delete_time_in_millis": 98,"delete_current": 0,"noop_update_total": 0,"is_throttled": false,"throttle_time_in_millis": 0},"get": {"total": 0,"time_in_millis": 0,"exists_total": 0,"exists_time_in_millis": 0,"missing_total": 0,"missing_time_in_millis": 0,"current": 0},"search": {"open_contexts": 0,"query_total": 1328,"query_time_in_millis": 1884,"query_current": 0,"fetch_total": 6,"fetch_time_in_millis": 131,"fetch_current": 0,"scroll_total": 3,"scroll_time_in_millis": 1412,"scroll_current": 0,"suggest_total": 0,"suggest_time_in_millis": 0,"suggest_current": 0},"merges": {"current": 0,"current_docs": 0,"current_size_in_bytes": 0,"total": 0,"total_time_in_millis": 0,"total_docs": 0,"total_size_in_bytes": 0,"total_stopped_time_in_millis": 0,"total_throttled_time_in_millis": 0,"total_auto_throttle_in_bytes": 62914560},"refresh": {"total": 15,"total_time_in_millis": 176,"external_total": 12,"external_total_time_in_millis": 186,"listeners": 0},"flush": {"total": 6,"periodic": 0,"total_time_in_millis": 4303},"warmer": {"current": 0,"total": 9,"total_time_in_millis": 0},"query_cache": {"memory_size_in_bytes": 0,"total_count": 0,"hit_count": 0,"miss_count": 0,"cache_size": 0,"cache_count": 0,"evictions": 0},"fielddata": {"memory_size_in_bytes": 1456,"evictions": 0},"completion": {"size_in_bytes": 0},"segments": {"count": 9,"memory_in_bytes": 92804,"terms_memory_in_bytes": 73152,"stored_fields_memory_in_bytes": 4584,"term_vectors_memory_in_bytes": 0,"norms_memory_in_bytes": 10304,"points_memory_in_bytes": 0,"doc_values_memory_in_bytes": 4764,"index_writer_memory_in_bytes": 0,"version_map_memory_in_bytes": 0,"fixed_bit_set_memory_in_bytes": 0,"max_unsafe_auto_id_timestamp": -1,"file_sizes": {}},"translog": {"operations": 0,"size_in_bytes": 165,"uncommitted_operations": 0,"uncommitted_size_in_bytes": 165,"earliest_last_modified_age": 24819785},"request_cache": {"memory_size_in_bytes": 348918,"evictions": 0,"hit_count": 174,"miss_count": 114},"recovery": {"current_as_source": 0,"current_as_target": 0,"throttle_time_in_millis": 0}},"total": {"docs": {"count": 36927,"deleted": 5767},"store": {"size_in_bytes": 13069189,"reserved_in_bytes": 0},"indexing": {"index_total": 0,"index_time_in_millis": 0,"index_current": 0,"index_failed": 0,"delete_total": 1444,"delete_time_in_millis": 98,"delete_current": 0,"noop_update_total": 0,"is_throttled": false,"throttle_time_in_millis": 0},"get": {"total": 0,"time_in_millis": 0,"exists_total": 0,"exists_time_in_millis": 0,"missing_total": 0,"missing_time_in_millis": 0,"current": 0},"search": {"open_contexts": 0,"query_total": 1328,"query_time_in_millis": 1884,"query_current": 0,"fetch_total": 6,"fetch_time_in_millis": 131,"fetch_current": 0,"scroll_total": 3,"scroll_time_in_millis": 1412,"scroll_current": 0,"suggest_total": 0,"suggest_time_in_millis": 0,"suggest_current": 0},"merges": {"current": 0,"current_docs": 0,"current_size_in_bytes": 0,"total": 0,"total_time_in_millis": 0,"total_docs": 0,"total_size_in_bytes": 0,"total_stopped_time_in_millis": 0,"total_throttled_time_in_millis": 0,"total_auto_throttle_in_bytes": 62914560},"refresh": {"total": 15,"total_time_in_millis": 176,"external_total": 12,"external_total_time_in_millis": 186,"listeners": 0},"flush": {"total": 6,"periodic": 0,"total_time_in_millis": 4303},"warmer": {"current": 0,"total": 9,"total_time_in_millis": 0},"query_cache": {"memory_size_in_bytes": 0,"total_count": 0,"hit_count": 0,"miss_count": 0,"cache_size": 0,"cache_count": 0,"evictions": 0},"fielddata": {"memory_size_in_bytes": 1456,"evictions": 0},"completion": {"size_in_bytes": 0},"segments": {"count": 9,"memory_in_bytes": 92804,"terms_memory_in_bytes": 73152,"stored_fields_memory_in_bytes": 4584,"term_vectors_memory_in_bytes": 0,"norms_memory_in_bytes": 10304,"points_memory_in_bytes": 0,"doc_values_memory_in_bytes": 4764,"index_writer_memory_in_bytes": 0,"version_map_memory_in_bytes": 0,"fixed_bit_set_memory_in_bytes": 0,"max_unsafe_auto_id_timestamp": -1,"file_sizes": {}},"translog": {"operations": 0,"size_in_bytes": 165,"uncommitted_operations": 0,"uncommitted_size_in_bytes": 165,"earliest_last_modified_age": 24819785},"request_cache": {"memory_size_in_bytes": 348918,"evictions": 0,"hit_count": 174,"miss_count": 114},"recovery": {"current_as_source": 0,"current_as_target": 0,"throttle_time_in_millis": 0}}}}
}

 

二、数据操作类

   数据在索引下称之为文档,以下也称之为文档

1、查询某个索引下的所有文档数据(GET /索引/_search)

localhost:9200/my_index/_search?pretty

 

 

 

2、查询某个索引下的某个文档ID对应的数据(GET /索引/_doc/文档ID/ )

http://10.19.214.13:9200/索引/_doc/文档ID

3、修改指定索引下的某个文档(POST 根据文档ID找到对应文档进行修改)

http://10.19.214.13:9200/索引/_doc/文档ID/_update

 

Postman 调用接口更改数据

通过  http://10.19.214.13:9200/data_iotrm_event_event_acs%240x00030403_2024-10-29/_doc/oxcqTJMBXFMQjG9sdTdP/  接口 查看该文档对应的数据

4、删除指定索引下的某个文档(DELETE /索引/_doc/文档ID)

 http://10.19.214.13:9200/data_iotrm_event_event_acs%240x00030403_2024-10-29/_doc/SBcoTJMBXFMQjG9sdTZM/

 

 再次根据这个文档ID 查看是否已经被删除

5、某个索引下新增一个文档(POST/索引/_doc/docID)

http://10.19.214.13:9200/data_iotrm_event_event_acs%240x00030403_2024-10-29/_doc/1   在索引 data_iotrm_event_event_acs$0x00030403_2024-10-29 下创建一个ID为1的文档数据

查看新增的数据

6、删除指定索引下的所有文档(POST /索引/_delete_by_query?pretty)当索引为* 表示删除所有索引下的所有文档数据

request body

{
  "query": {
    "match_all": {}
  }
}

示例

 elastic head 通过谷歌浏览器已经连接上es,可以看到目标索引下的信息

可以看到索引“iotrm_event_event_acs$0x00030403_2024-10-29” 下有36700个文档

当下通过API将删除该索引下的所有数据

打开 Postman 输入 http://10.19.214.13:9200/iotrm_event_event_acs%240x00030403_2024-10-29/_delete_by_query?pretty    (注意:iotrm_event_event_acs$240x00030403_2024-10-29 索引ID,由于其中含有$,需要将这个字符变成%24 )

request body

{
  "query": {
    "match_all": {}
  }
}

由上图可知删除了 36700 条数据

刷新 elastichead 可以看到该索引下的数据

 8、统计文档总数(GET _cat/indices)

curl -u elastic:elasticsearch_422 http://10.19.223.119:9200/_cat/indices |awk 'BEGIN{total=0}{total+=$7}END{print total}'

三、快照仓库操作类

1、仓库操作类

1)查看当前所有的仓库(GET _snapshot)

  http://10.19.214.13:9200/_snapshot

2)注册仓库(PUT _snapshot)

{"type": "fs","settings": {"location": "/opt/es/backup/iotrm"}
}

如果location 的地址在 es 的配置文件 elasticsearch.yml 中没有配置,那么会报下面这个错误

[iotrm] location [/opt/es/backup/iotrm] doesn't match any of the locations specified by path.repo

配置

  • elasticsearch.yml 中仓库配置如下:
path.repo: /opt/xx/web/xx/elasticsearch.1/data/backup,/opt/es/backup/iotrm

多个仓库地址用逗号隔开

  • 每个仓库地址必须和elasticsearch 启动用户是同一个,如es 启动账号是 es ,分组也是 es,则 这里 /opt/es/backup/iotrm 需要属于es,可以通过命令 chown -R es:es /opt/es/backup  设置
  • 重启es服务

如果不将仓库地址设置成 es 启动用户一致,则注册仓库会报如下错误

注册

注册成功的返回信息如下:

3)删除已经注册的快照仓库(DELETE /_snapshot/仓库名称)

 

4)审查快照仓库并删除未被快照引用的过时数据(POST /_snapshot/仓库名称/_cleanup)

 

5)手动校验快照仓库是否可用(POST _snapshot/仓库名称/_verify)

 

2、快照操作类

1)查看某个仓库下所有快照(GET _snapshot/仓库名称/*)

http://10.19.223.119:9200/_snapshot/iotrm/*

2)在某个仓库下创建快照(PUT _snapshot/仓库名/快照名称?wait_for_completion=true)

http://10.19.223.119:9200/_snapshot/iotrm/%3Ciotrm-%7Bnow%7ByyyyMMddHHmmss%7D%7D%3E?wait_for_completion=true    快照名称可以配置时间格式,%3Ciotrm-%7Bnow%7ByyyyMMddHHmmss%7D%7D%3E 实际是:<iotrm-{now{yyyyMMddHHmmss}}>

请求body

{"include_global_state": false,"indices":["iotrm*"],"metadata": {"taken_by": "wangfang5","taken_because": "iotrm,backup test"}
}

表示将  iotrm 开头的所有索引进行备份

返回内容

    "snapshot": {"snapshot": "iotrm-20241203072538","uuid": "idfOxhbCR961R6o3IiKpKQ","version_id": 7100299,"version": "7.10.2","indices": ["iotrm_xx_2024-09-12","iotrm_xx","iotrm_yy","iotrm_xx$0x00070101_2024-11-30","iotrm_yy_2024-09-12"],"data_streams": [],"include_global_state": false,"metadata": {"taken_by": "wangfang5","taken_because": "iotrm,backup test"},"state": "SUCCESS","start_time": "2024-12-03T07:25:38.909Z","start_time_in_millis": 1733210738909,"end_time": "2024-12-03T07:29:24.148Z","end_time_in_millis": 1733210964148,"duration_in_millis": 225239,"failures": [],"shards": {"total": 5,"failed": 0,"successful": 5}}
}

3)还原某个仓库下的快照(POST _snapshot/仓库名称/快照名称/_restore?wait_for_completion=true)

 http://10.19.214.13:9200/_snapshot/iotrm/iotrm-20241203072538/_restore?wait_for_completion=true

响应内容

{"snapshot": {"snapshot": "iotrm-20241203072538","indices": [

"iotrm_xx_2024-09-12",
            "iotrm_xx","iotrm_yy","iotrm_xx$0x00070101_2024-11-30","iotrm_yy_2024-09-12"
 ], "shards": { "total": 5, "failed": 0, "successful": 5} } }

4) 从某个仓库的某个快照进行还原,但是指定还原的索引(POST _snapshot/仓库名称/快照名称/_restore?wait_for_completion=true

http://10.19.214.13:9200/_snapshot/total/all-20241203124406/_restore?wait_for_completion=true

 请求body

{"indices": "test_event_illuminancetelemeter"
}

 响应body

{"snapshot": {"snapshot": "all-20241203124406","indices": ["test_event_illuminancetelemeter"],"shards": {"total": 3,"failed": 0,"successful": 3}}
}

5)在某个仓库下删除快照(DELETE /_snapshot/仓库名称/快照名称)

 http://10.19.223.119:9200/_snapshot/es_data_repository/es_data_repository-20241128000000

四、节点操作类

1、查询所有节点的索引搜索信息(GET /_nodes/stats/indices/search)

2、查询节点资源占用情况(GET /_cat/nodes)

http://10.19.223.119:9200/_cat/nodes?format=json

也可以使用参数 v&format 控制输出格式

3、查看版本信息(GET /)

http://10.19.223.119:9200/

还可以通过 elasticsearch 工具查询:elasticsearch --version

五、集群

1、查看集群健康信息(GET /_cluster/health)

http://10.19.223.119:9200/_cluster/health

2、查看某个索引在集群内的分片健康状态(GET _cluster/health/索引名称?level=shards)

http://10.19.214.18:9200/_cluster/health/iotrm_event_event_acs%240x00030219_2024-09-12?level=shards

 

{"cluster_name": "hik-ga-es","status": "yellow","timed_out": false,"number_of_nodes": 1,"number_of_data_nodes": 1,"active_primary_shards": 3,"active_shards": 3,"relocating_shards": 0,"initializing_shards": 0,"unassigned_shards": 3,"delayed_unassigned_shards": 0,"number_of_pending_tasks": 0,"number_of_in_flight_fetch": 0,"task_max_waiting_in_queue_millis": 0,"active_shards_percent_as_number": 54.51327433628319,"indices": {"iotrm_event_event_acs$0x00030219_2024-09-12": {"status": "yellow","number_of_shards": 3,    #3个主分片"number_of_replicas": 1,   #1个副本,即每个主片都有一个副本"active_primary_shards": 3,"active_shards": 3,"relocating_shards": 0,"initializing_shards": 0,"unassigned_shards": 3,   #3个分片未分配,这是因为这是单es节点,而该索引创建的时候指明了需要1个副本,因此这里3表示未分配3个副本分片"shards": {"0": {"status": "yellow","primary_active": true,"active_shards": 1,"relocating_shards": 0,"initializing_shards": 0,"unassigned_shards": 1},"1": {"status": "yellow","primary_active": true,"active_shards": 1,"relocating_shards": 0,"initializing_shards": 0,"unassigned_shards": 1},"2": {"status": "yellow","primary_active": true,"active_shards": 1,"relocating_shards": 0,"initializing_shards": 0,"unassigned_shards": 1}}}}
}

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/846594.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

为什么Unity里的变体数和UWA工具测出来的不一样

1)为什么Unity里的变体数和UWA工具测出来的不一样2)使用TextureArray为什么会导致L1 Cache Miss率变高3)Gfx.PresentFrame耗时异常高4)AO方案中哪个更适合移动端这是第412篇UWA技术知识分享的推送,精选了UWA社区的热门话题,涵盖了UWA问答、社区帖子等技术知识点,助力大家…

abb喷涂机器人维修齿轮泵电机不转了怎么办?

ABB喷涂机器人齿轮泵电机常见的故障表现有哪些?1、电机振动过大:这可能是由于电机安装不当、轴承磨损或者不平衡导致的。振动过大会影响电机的稳定性和工作效率。2、电机无法启动:这可能是由于电源故障、电机内部短路或者过载保护触发导致的。无法启动会导致生产线停工,影响…

Android 添加指定QQ或加群

原文地址: Android 添加指定QQ或加群-Stars-One的杂货小窝实际上,原理就是通过scheme来唤起手机QQ进行对应的操作 添加QQ import android.content.Context import android.content.Intent import android.net.Uri import com.blankj.utilcode.util.ToastUtilsobject QqUtils {f…

【AIX】AIX系统安装教程及相关命令

⼀、 安装教程 1、unix是从MULTICS操作系统演变⽽来,MULTICS的特征是啥?终端!咱们通过串⼝去连接IBM P740吧,⾸先得准备USB转串⼝线2、 就是这种了,按照下图连接3、连接正常后(这⾥⽤的是win10操作系统),可以在设备管理那⾥看到安装正确的串⼝(这⾥是COM3⼝)(没正确…

MySQL: 划分具有连续相同值的区间

需求 有一组数据,第一列是类型A/B,第二列是操作时间,怎么取出不同类型不同时间段的最大、最小操作时间? 输入:输出:建表语句: create table test2 (`type` varchar(5),`time` timestamp )engine=innodb;insert into test2 values (A, 2021-08-09 10:00:00), (A, 2021-08…

VMware虚拟机磁盘扩容

环境:linux 系统:ubuntu1.修改磁盘配置2.在虚拟机内部系统分配空间 运行以下命令: sudo apt update sudo apt install gparted gparted启动如下界面:sda2右键选择“Resize/Move”free space following直接输入0,回车确认,数值会自动变成下图的样子应用修改检查是否修改成…

究竟何种办公软件适合广告公司团队协作?

在当今竞争激烈的广告行业中,团队协作的效率至关重要。拥有一款强大的可视化团队协同办公软件,能够极大地提升广告公司的工作效率和项目管理水平。下面,我们将为大家盘点 6 款可视化团队协同办公软件,其中包括备受好评的板栗看板,以及国外的 5 款相关软件。 一、板栗看板 …

vxe-table 一键切换编辑模式、只读模式

vxe-table 可以编辑模式和只读模式的参数是 editConfig.enabled 当需要编辑时就启用,当不需要编辑时就关闭 官网:https://vxetable.cn/<template><div><vxe-button status="primary" @click="toggleReadonly">切换</vxe-button>…

RK3566 RK3568开发板Android11屏蔽开机启动提示,优化启动时间

触觉智能RK3568开发板Android11屏蔽开机启动提示,优化启动时间!通用瑞芯微RK3566 RK3568等主板在Android11系统下开机启动会出现下图“平板电脑正在启动”字样,屏蔽可优化开机启动时间,本文教大家如何通过修改代码屏蔽开机提示。使用触觉智能EVB3568鸿蒙开发板演示,搭载瑞…

jQuery实现类似视频播放功能的图片播放器插件

jquery Image Player是一款可以像视频播放一样逐张播放图片的图片播放器JQUERY插件。当你需要介绍你的某个产品和项目的时候,这个插件就可以发挥它的强大作用。你可以将产品或项目的各个功能做成图片,然后使用该插件来逐帧播放。 现在大多数的产品和项目介绍使用的都是gif图片…

Nexpose 7.0.0 for Linux Windows - 漏洞扫描

Nexpose 7.0.0 for Linux & Windows - 漏洞扫描Nexpose 7.0.0 for Linux & Windows - 漏洞扫描 Rapid7 on-prem Vulnerability Management, released Dec 03, 2024 请访问原文链接:https://sysin.org/blog/nexpose-7/ 查看最新版。原创作品,转载请保留出处。 作者主页…

采集倍福PLC 转 profinet IO项目案例

VFBOX协议转换网关支持PLC,modbus,EthernetIP,Profinet,CCLink,EtherCAT,IEC61850,IEC104,bacnet,DLT645,HJ212,opc ua,opc da,DNP3。目录 1 案例说明 1 2 VFBOX网关工作原理 1 3 准备工作 2 4 设置倍福PLC 2 5 配置网关参数采集倍福PLC数据 4 6 用PROFINET IO协议…