常用API
查看集群健康状态
curl -s 192.168.1.27:9200/_cluster/health | jq .status查看集群状态
curl -s 192.168.1.27:9201/_cluster/state | jq
curl -s 192.168.1.27:9201/_cluster/state/nodes | jq查看集群统计信息
curl -s 192.168.1.27:9201/_cluster/stats | jq查看集群的设置及优先级
curl -s 192.168.1.27:9201/_cluster/settings
curl -s 192.168.1.27:9201/_cluster/settings?include_defaults=true | jq修改集群设置
# 修改集群分片分配方式 (all / primaries / new_primaries / none)
curl -X POST 192.168.1.27:9200/_cluster/settings \
-H "Content-Type: application/json" \
-d '{
"transient": {
"cluster.routing.allocation.enable": "none"
}
}'查看集群的分片分配情况
curl 192.168.1.27:9200/_cluster/allocation/explain \
-H "Content-Type: application/json" \
-d '{
"index": "study-01",
"shard": 0,
"primary": true
}'查看集群的分片重路由
curl -X POST 192.168.1.27:9200/_cluster/reroute \
-H "Content-Type: application/json" \
-d '{
{
"commands": [
{
"move": {
"index": "study-03",
"shard": 0,
"from_node": "k8s03",
"to_node": "k8s01"
}
}
]
}
}'取消副本分片的分配,副本分片会重新初始化分配
curl -X POST 192.168.1.27:9200/_cluster/reroute \
-H "Content-Type: application/json" \
-d '{
{
"commands": [
{
"cancel": {
"index": "study-03",
"shard": 0,
"node": "k8s02"
}
}
]
}
}'Last updated