查看集群节点

curl http://$IP:9200/_cat/nodes?v

查看集群健康状态

curl http://$IP:9200/_cluster/health?pretty 

查看索引

curl http://$IP:9200/_cat/indices/?v

查看索引,需要账号密码情况下

curl --user elastic:password http://$IP:9200/_cat/indices?v
### 密码有特殊字符的需要使用单引号
curl --user 'elastic:password' 192.168.1.121:9200/_cat/indices

格式化显示索引信息

curl http://$IP:9200/index_test?pretty 

得到集群中节点的相关信息

curl -XGET http://$IP:9200/_cluster/nodes/

关闭整个集群

curl -XPOST http://$IP:9200/_cluster/nodes/_shutdown

关闭集群中指定节点

curl -XPOST http://$IP:9200/_cluster/nodes/aaaa/_shutdown

创建名为dbs的索引

curl -XPOST http://$IP:9200/dbs

删除名为dbs的索引

curl -XDELETE http://$IP:9200/dbs

删除名为dbs-xxxx的索引

# 一般用于删除指定日期的索引
curl -XDELETE http://$IP:9200/dbs-*

删除多个指定索引,中间用逗号隔开

curl -XDELETE http://$IP:9200/acc-apply-2018.08.09,acc-apply-2018.08.10

手工查询指定索引数据

curl -H "Content-Type: application/json" -XPOST http:$IP:9200/索引名/_search?pretty -d '{"query": { "match_all": {} }, "size": 1}'

修改索引只读

# 磁盘满了会导致es的索引只读,清理磁盘空间后可以执行如下命令修改索引只读
curl -XPUT -H "Content-Type: application/json" http://$IP:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete":null}'
作者:于浩  创建时间:2024-02-05 15:29
最后编辑:于浩  更新时间:2024-02-06 11:18