有个需求,需要查看当前Elasticsearch集群有多少个节点。

Get请求的话:

http://127.0.0.1:9200/_nodes

返回示例:

{
"_nodes": {
"total": 1,
"successful": 1,
"failed": 0
},
"cluster_name": "vis-search",
"nodes": {
"OeI6lCdnTvah7ZAIN681jA": {
...
}
}
}

PHP取集群节点数量示例:

$return  = $this->client->nodes()->stats();
$nodeNum = $return['_nodes']['total'];

相关参考:Nodes info API



Related Posts: Elasticsearch-PHP获取ES集群节点信息 :

留言