# 查询索引状态,health列结果为green/yellow表示正常
curl -u 账号:密码 -X GET http://<CLUSTER-IP>:9200/_cat/health?v
# 索引状态查询
curl -u 账号:密码 -X GET http://<CLUSTER-IP>:9200/_cat/indices?v
# 占用内存信息查询
curl -u 账号:密码 -X GET <CLUSTER-IP>:9200/_cat/nodes?v\&h=host,heap.current,heap.percent,heap.max,ram.max,disk.avail,node.role,m
# 列出所有索引
curl -u 账号:密码 -X GET http://<CLUSTER-IP>:9200/_cat/indices?v
# 查看某项索引的x个数据
curl -u 账号:密码 -X GET http://<CLUSTER-IP>:9200/<索引项>/_search?size=<数据数>
#新建索引
curl -X PUT "http://localhost:9200/my_new_index"
# 删除索引,高危操作,谨慎执行
curl -u 账号:密码 -XDELETE http://127.0.0.1:9200/<索引名称>
#重建索引
POST _reindex { "source": { "index": "twitter" }, "dest": { "index": "new_twitter", "version_type": "internal" }
解除只读模式
curl -u "elastic:Do1Portal_2023" -X PUT "localhost:9200/.kibana_7.17.23_001/_settings" -H "Content-Type: application/json" -d' { "index.blocks.read_only_allow_delete": null }'
查看分片无法分配下去的原因
GET /_cluster/allocation/explain?pretty
让Elasticsearch尝试重新分配那些之前分配失败的分片。
POST /_cluster/reroute?retry_failed=true
问题记录:
报错信息
"a copy of this shard is already allocated to this node [[app-logs-2024.10.13][0], node[dx2fd95lRIOZGabUpOq9ew], [P], s[STARTED], a[id=fsuoPYKwTxeMjpvz_IY_5Q]]
[root@VM-16-30-centos logs]# curl -X PUT -u "es:xxxxx456" "http://127.0.0.1:9200/app-logs-2024.10.13/_settings" -H 'Content-Type: application/json' -d' { "index": { "number_of_replicas": 0 } }